Click here to Skip to main content
1,823 members
Articles / Windows
Tip/Trick

Backing up My Documents in Windows 7 with robocopy

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
20 Jul 2012CPOL 25.3K  
How to use robocopy to backup your My Documents Folder

Backing up your My Documents folder in Windows 7

This should be as easy as something like:

robocopy c:\users\vince\Documents \\remotestoragelocation\foldername /MIR

The /MIR switch will mirror the first folder onto the second folder (Keep in mind this will also remove the files you delete), If you want to just copy the files and not delete the ones you have deleted in your backup then you can use /E instead of /MIR

The tricky part is that you may encounter an error when it gets to a few folders like My Music etc... This is because they are junction folders and they won't copy properly.

Don't worry you can still backup your Documents Folder and skip those Junction folders. You just need to also use the /XJ switch.

robocopy c:\users\vince\Documents \\remotestoragelocation\foldername /MIR /XJ
or
robocopy c:\users\vince\Documents \\remotestoragelocation\foldername /E /XJ

Now in the documentation it says the /XJ switch is "Normally included by default" however Normally doesn't mean always. So put it in to be safe.

You can put this into a .bat file or set it up as scheduled task to be run periodically. For me personaly as an Admin I don't like to use scheduled tasks for backups. The reason is that a scheduled task is typically setup once and forgotten about. It will run perfectly fine for the most part. However I have seen windows updates, persmisions, folder name changes etc... that can mess up your task and you don't even know it hasn't been running for months until you need to do a restore and nothing is there. You can of course setup some notification system for your task but then you need to monitor for that notification system. What if that fails? Are you monitoring your notification system? Is it redundant?

It is a far better option in my mind to put this on the end user to mindfully click on the backup bat file. Once it becomes a habbit to do this its a quick thing to do and they can be assured it completes without error.

There are of course other options for backing up like an Server side backup system, windows backup, ziping or raring your files to an archive, but for MyDocuments a /MIR or /E is usually good enough. It also a bit less fumbly for people to find there files in case they need to. Also sometimes you just want to make a quick copy.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
-- There are no messages in this forum --