Rsync for easy (and quick) backups
I’ve got to say, I haven’t spent ENOUGH time with rsync to really be fluent in how I could put it to use…. A week or so ago I was reading this list of essential Linux software by a guy that moved from Mac OS X to linux because he detested the DRM that was being shoved down his throat. Anyway, one of his essentials was rsync for backups. Which got me thinking. Why didn’t I use rsync for backups. At one point in time I used unison, but for some reason had stopped and was in need of reorganizing my home backup strategy anyway. I found a few interesting approaches.
This “Link Backup” script is an interesting approach and seems like a good idea. Essentially files on disc can have more than one “hard link” (*think of a filename) pointing to it and so… they copy everything once and then just copy the changes on incremental backups making hard links to the already existing-unchanged files. From the site:
Link-Backup is a backup utility that creates hard links between a series of backed-up trees, and intelligently handles renames, moves, and duplicate files without additional storage or transfer.
Transfer occurs over standard i/o locally or remotely between a client and server instance of this script. Remote backups rely on the secure remote shell program ssh.
Link-Backup comes with a web based viewer of the backups it makes.
One of the beauties of rsync is that it can work locally, or over the network, it can use ssh for encryption… in sum it gives you some options that are really handy. But the real kicker is this…. the rsync algorithm is fairly clever. Let’s say I rsync my home directory – 15GB worth to a removable drive. The first time, this will take quite a while. The second time… rsync looks and sees what files have changed and even what PARTS of those files have changed, it winds up saving a good deal of time in successive rsync runs over the first run. Here’s a basic rsync how-to. You would think from the name that it would automatically “synchronize” two different directories. However it doesn’t do that by default. It is designed more to “make the second folder look like the first folder”. Which is a SLIGHTLY different concept. However, it CAN be used to do a two way synchronization….
rsync -avu folder1/* folder2/
for instance would copy changed files from folder1 to folder 2 without deleting files, without clobbering newer files in folder2. The next line does the same from folder2 to folder1. The only problem might be encountered with a file that is independently edited in the two locations. Of course, you run into problems with that in MOST ANY synchronization scheme.
rsync -avu folder2/* folder1/
Another good reference on “easy automated snapshot backups using rsync” is here. This one goes into some good detail and makes use of a feature in rsync to deal with hard links. Rsync is available for Windows as well.
While I’m at it, let me not forget the rsync.net file storage service where for a few dollars a month you can store a few GB of data…. (It’s not connected to the originator of the rsync protocol.) So, it might be worth looking into if you’re interested in working up a good backup strategy.