Friday, February 15, 2008
Robocopy for Mirroring Directory(ies) to a Backup Disk
I did quite a bit of looking around for a way to backup my documents and music and other files on my new Vista PC. I have a second disk in my system and wanted to mirror my important data to that second disk. There's a backup utility built in to Vista, but it doesn't have a way to exclude directories (!) and I have some directories with large, static data that I already have backed up elsewhere and don't want to include on the backup disk.
I found a bunch of mirroring tools, and none seemed very good. I don't need it to run unattended, because I remember to do it often enough and also I don't leave my PC on overnight usually.
I settled on Robocopy.exe, a command-line tool that isn't in Vista by default but I was able to get it by installing the Windows 2003 Resource Kit. Robocopy is working great for me. It took some effort to figure out the command-line switches, but now I have a batch file that I can run once in awhile to mirror my important data to my backup disk. It's been reliable, synchronizes directories by deleting files in the destination that have been deleted in the source, and is very fast by not copying files that are already sync'd.
Here's the command I'm using to mirror my user folder on the backup disk:
robocopy "c:\Users\Ryan" "e:\Sync Folder\Ryan" /MIR /XJ /R:1 /ZB /S /W:1 /XD "AppData" /XF "ntuser.*"
I found a bunch of mirroring tools, and none seemed very good. I don't need it to run unattended, because I remember to do it often enough and also I don't leave my PC on overnight usually.
I settled on Robocopy.exe, a command-line tool that isn't in Vista by default but I was able to get it by installing the Windows 2003 Resource Kit. Robocopy is working great for me. It took some effort to figure out the command-line switches, but now I have a batch file that I can run once in awhile to mirror my important data to my backup disk. It's been reliable, synchronizes directories by deleting files in the destination that have been deleted in the source, and is very fast by not copying files that are already sync'd.
Here's the command I'm using to mirror my user folder on the backup disk:
robocopy "c:\Users\Ryan" "e:\Sync Folder\Ryan" /MIR /XJ /R:1 /ZB /S /W:1 /XD "AppData" /XF "ntuser.*"
- /MIR means make the output directory just like the source directory, including deleting files
- /XJ means exclude junction points
- /R:1 means only retry failed copies once, I look at the output for errors anyway, and don't expect any on internal disk to internal disk copy
- /ZB use restartable mode
- /S copy subdirectories too, but not empty ones
- /W:1 wait only 1 second between retries, I did this for the same reasons as /R:1
- /XD "AppData" Exclude the AppData subdirectory which has a bunch of temporary files I don't need backed up
- /XF "ntuser.*" Exclude ntuser.* log files, don't need them backed up and they're usually in use
Subscribe to Posts [Atom]