Monday, December 7, 2009

Backup

Do you remember that song

Yesterday,
All those backups seemed a waste of pay.
Now my database has gone away.
Oh I believe in yesterday.

...

Recently I've decided it's high time I set up a decent backup for my growing collection of photos, videos and of course my projects.

So I got a nifty Samsung S2 USB HDD.
As most external 2.5" drives, it is powered by the USB, so I have only one cable plug in.
Although it came with backup software, it didn't quite meet my expectations.
I was looking for a simple yet efficient solution. Then robocopy came into my mind. I knew it was the heavy-lifting tool for moving files around in Windows environment. Then I was pleasantly surprised it has become a standard Windows tool since Vista. Then it turned out /MIR option does exactly what I need - mirror a directory tree.
In couple of minutes I came up with a simple .bat file that replicates a set of directories. It looks something like this (triple percent sign is no typo)

SET TARGET=F:\BACKUP
FOR /F "eol=#" %%I IN (backup.lst) DO robocopy %%I %TARGET%%%~pnI /mir


Here backup.lst contains a list of directories to backup, e.g.
#  Backup list
D:\Photos
D:\projects
D:\Video


These are replicated to

F:\BACKUP\Photos
F:\BACKUP\projects
F:\BACKUP\Video

respectively

First run does take some time to copy about 100G at ~20M/s. But after that it's quite fast as it copies only what has changed. Using external HDD for backup allows to go without compression which improves performance and also the backup can be readily used if necessary.

Now my important data feels safer.