Monday, January 17, 2011

Simple Backups with Robocopy

Of course, everyone backs up their hard drives, right?  If your system crashes, how much would you lose?  Most likely, something, but I like to try and minimize that answer – I ‘d rather not answer “everything.”

For backing up my C: drive partition, I use Acronis True-Image Home.  I backup the entire C: drive image so I can rebuild it in the event of a catastrophic failure.

Like many other people, however, I have data drives.  To be a little more specific, I have 1TB partitions for “DATA_HOME” and “DATA_WORK”.  These two 1TB partitions will fit on a 2TB HD no problem, but using Acronis is not what I want to do.  Why?  Because Acronis creates a giant backup file (and possibly subsequent incremental backup files) that I need Acronis in order to use.  In addition, if I wanted to create a new backup, I would (due to space reasons) need to delete my old backup before creating the new one.  This is a small window of opportunity for disaster, but one that I will avoid if I can.  And you can.  Easily.  I very much like the idea of having a copy of my data on a separate hard drive that I can access from any computer, without Acronis.

I did some searching around for a good solution and found a utility from Microsoft called “SyncToy”.  At the time I used it, and still now, the most recent is version 2.1.  SyncToy would create a mirror image of my DATA_HOME and DATA_WORK partitions into DATA_HOME and DATA_WORK folders on the 2TB hard drive.  Whenever I wanted to do a backup, I would stick the 2TB backup hard drive into my eSATA slot and run SyncToy to “echo” my partitions to folders on the backup drive.  All seemed good in the world.

But then I noticed a missing folder.  Two, actually.  So I ran SyncToy again to echo the data.  But SyncToy wouldn’t copy the files.  It turned out there was a lot of missing data on the backup.  SyncToy said it had done everything it needed to do and no errors were encountered.  Yet, I could easily verify that there was 22GB (out of 400GB) that was MISSING on my external HD backup!  NOT GOOD!  I verified that the folders and files would not be excluded for some reason (System attribute set? nope!).  I could find no reason.  And so, my trust for SyncToy was lost.  I could not get SyncToy to copy the missing files.  Time to look for an alternative.

Being a software engineer, I thought I would write something myself.  But being a busy person, I didn’t have a lot of time to do that.  So I looked up an old utility I read about that’s included with Windows Vista, 2003 and 7.  It’s a command-line program called ROBOCOPY and it was written a long time ago, in an office far far away.  But it does just the trick.  I ran Robocopy and the 23GB of missing files moved over to the target folder.  Problem solved.

To run Robocopy, I run it with these options:


This would copy my G: drive (DATA_HOME) to the backup folder E:\DATA_HOME.  The /MIR option does a mirror operation – copying stuff in the source not in the destination and deleting stuff in the destination that is no longer in the source.  The /XD option is used to exclude the protected Recycle Bin and System Volume Information folders.

Note: you can use the /L parameter (LIST only) and it will go through the motions but not actually do any copying.  At the end of the process, you get a little report of what it would do (or what if did, if you omit the /L option.)

Here is the final report after copying my DATA_WORK partition.  About 75.2GB was copied and it took 4 minutes 18 seconds to complete.


A simple batch file, to copy the folders I want backed up, makes backing up my extra partitions and files a snap.  There is another program from Microsoft out there called “RichCopy”, which is newer offering.  I have not spent any time playing with it.  Also, Robocopy has a GUI front-end that you can download and install.  Just google “robocopy gui” to find it.


Christoffer said...

As a follow up, I noticed that the target/backup folder was not visible after Robocopy completed. I beleive this is due to the source being the ROOT folder of the drive, which is marked as SYSTEM and HIDDEN (?). So after Robocopy finishes, the batch file does an ATTRIB to make the folder visible again:

ROBOCOPY F:\ E:\DATA_WORK\ /MIR /XD "$RECYCLE.BIN" "System Volume Information" "RECYCLER"



Unknown said...

Data failures could be possible that may cause hard disk failure. Data backup becomes very important in such scenarios, which often a lot of people are not aware of. Get an application with good brand popularity already in the market along with open terms and conditions. The article has given me best guidelines. Thanks
pst recovery

wahid said...

I suggest to try "Long Path Tool" program. It’s really work for me.

Micheal Alexander said...

Congratulation for the great post. Those who come to read your Information will find lots of helpful and informative tips. Download RichCopy