Windows RoboCopy Backup
Jul 16, 2015
This simple batch file has the ability to backup multiple folders using Robocopy or a single file using xcopy.
Robocopy
/MIR – Mirrors a directory tree /FFT – Assumes FAT file times (two-second precision) /Z – Copies files in Restart mode /R:3 – Specifies the number of retries on failed copies /W:3 – Specifies the wait time between retries, in seconds /A-:SH – Removes system and hidden attributes
http://technet.microsoft.com/en-us/library/cc733145.aspx These arguments for Robocopy will delete files from the destination directory if the file/directory no longer exist in the source directory.
xcopy
/i – If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. /Y – Suppresses prompting to confirm that you want to overwrite an existing destination file http://technet.microsoft.com/en-us/library/cc771254.aspx
Batch Script
@echo off
set drive=X:\Backup
robocopy C:\Folder %drive%\Folder /MIR /FFT /Z /R:3 /W:3 /A-:SH
xcopy C:\single_file_to_backup.txt %drive%\Folder /i /Y