Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Towards the innovative SQL ideas
Browse by Tags · View All
ms sql server 119
ms sql 118
sql server 116
sql 115
database 102
tsql 81
#SQL Server 78
t-sql 75
#sql 71
sql server general 67

Archive · View All
April 2011 14
July 2011 12
May 2011 12
August 2011 11
June 2011 10
September 2011 8
December 2011 6
November 2011 6
June 2013 5
April 2013 5

Copy database backup files using XCOPY command

Oct 12 2012 12:00AM by Paresh Prajapati   

Recently when I was working database backups copy to external drives or whatever destination , I tried it with new solution using XCOPY command. Before that solution I was using XP_CMDSHELL command in SQL Server to copy database backup file to external drive, also we should avoid to use XP_CMDSHELL for security concern.  So out of SQL server script\query and other tool, the solution came with XCOPY command which copy latest files or as per date specified, so later database backup files or the files created on or after date specified as input. You can visit XCOPY command here.

Lets first share me the command which I am using to copy latest database backup files. Here I am using some variables in the code, but let’s share me script first then I will explain the variables.

SET dwMONTH=%DATE:~4,2%
SET dwDAY=%DATE:~7,2%
SET dwYEAR=%DATE:~10,4%
SET dwDate=%dwMONTH%-%dwDAY%-%dwYEAR%

SET source=C:\DatabaseBackup
SET destination=\\externaldrive\DatabaseBackup\
SET extension=*.bak

XCOPY /Y %source%\%extension% %destination% /s /i /D:%dwDate% 

You can see batch file created with above code and the variables used inside and how they are integrated with final XCOPY command. after get to run it will copy database backup files to external drive or whatever destination using source, Destination, file extension (.bak or .trn here) and the date on or after the backup files created. Let’s implement and run it.

This code in batch files copy all the files created Today with specified file type from source folders including sub folders to destination. So lets run batch and see what’s inside. Lets try with sample example and local drives,

FilesCopy

Apart from XP_CMDSHELL command using in SQL Server, which methods you are using database backup files to external drives? Please share here. I will post further topic with different method for the same. Hope you enjoyed it.

Tags: Database,Backup,sql, sql server,mssql,XCOPY,XP_CMDSHELL,copy,command,external drive


Paresh Prajapati
6 · 22% · 7054
5
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • Generally, I'm not going to back up to local drives to begin with. I'll back up to a UNC (\server\share\directory\file.ext), or set up a mount point that redirects the file.

    If files always need to be copied or replicated to multiple destinations, I'll leverage the abilities of the OS or file system to do so (FRS - File Replication Service and/or DFS - Distributed File System). If the storage is SAN based, snapshots and snapshot replication is also an option.

    commented on Oct 12 2012 12:14PM
    Marc Jellinek
    97 · 2% · 546

Your Comment


Sign Up or Login to post a comment.

"Copy database backup files using XCOPY command" rated 5 out of 5 by 5 readers
Copy database backup files using XCOPY command , 5.0 out of 5 based on 5 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]