Friday, March 8, 2013

Use Robocopy for backup

robocopy <sourse> <destination> /e /mir /np /tee /mt:4 /log:backup_log.txt
robocopy <sourse> <destination> /e /mir /np /z /tee /mt /log+:backup_log.txt
pause

/e = copy all sub-folders, even empty ones
/mir = mirror (check the files in the destination, and only copy newer files)
/np = no progress counter
/log: = create a logfile
/log+: = This option ensures that the results of the 2nd and 3rd ROBOCOPY are appended to the log file created in the 1st ROBOCOPY line.
/tee = Output from ROBOCOPY written to both the log file and the cmd window.
/mt = ROBOCOPY also has the ability to perform faster multi-threaded copying by simply using the option /mt. I can choose the number of threads to use by specifying a number between 1 and 128 after the /mt option, or if I just specify /mt without a number then the it will use 8 threads by default. In the example below, I use 4 threads to copy to my USB drive, and 8 threads (no number) to copy to my network drive.
/z = This option implements a "retry" for the copying. If I were part way through the copying process, and I lost connection with the network, then ROBOCOPY would automatically restart the copying at the point of failure once the network connection was re-established.

#################################################################################################
WARNIG : Use the /MIR option with caution - it has the ability to delete a file from both the source and destination under certain conditions. This typically occurs if a file/folder in the destination has been deleted, causing ROBOCOPY to mirror the source to the destination. The result is that the same files in the source folder are also deleted. To avoid this situation, never delete any files/folders from the destination - delete them from the source, and then run the backup to mirror the destination to the source.
#################################################################################################

For more details

No comments: