Using rsync to take control of your backup process on OS X

Welcome to week two of Save Your Photos month! During this awareness month we usually focus—rightly so—on restoring, preserving, and archiving physical photos, but I’d like to take a moment this September to provide a tip that will be a massive time- and effort-saver for anyone on a UNIX system who’s a little bit handy with the computer. (Sorry, PC people, today’s particular tip is only for Mac OS X and Linux users.)

If you already use backup management software, you don’t have to worry about making sure that your files are distributed correctly… that’s what you bought the software for! If you’re like many people, however, it may not be that easy. For example, the complicating factors that drove me to find this solution were: I wanted to back up a 4 TB drive onto two 2 TB drives and, frankly, I didn’t want to pay for backup software.

So, what was I supposed to do? The two most obvious solutions were distasteful to me. I could wipe the drive and recopy all the files every time, but this would put unnecessary wear on the backup drive and is massively time consuming, as well as making backups less frequent. Alternatively, I could remember which files/folders had already been copied and just copy over the new content each backup, but even with a great deal of mental effort the fear of missing something would never completely go away.

Enter rsync. This simple yet powerful terminal command allows you to compare and synchronize two directories of your choice. In other words, configured correctly, you can tell your computer to make one directory exactly like another, including all subfolders and the files contained within! To use it on OS X, just open up the Terminal app in the Utilities subfolder of Applications and enter the command. Here’s the general formula:

rsync -[modifiers] “[source directory path]” “[target directory]”

Based on the general formula, here’s the specific formula on which I settled, with the source and target being modified for each drive. Thanks to the great craft brew community in this great state of Colorado, it’s easy to remember the modifiers I chose. Below, I’ll dissect those and elucidate some of the other modifiers you can use with the command. You can simply stack them up behind the hyphen of the second term, in whichever order you desire.

rsync ‐abv ‐‐backup-dir=”/Users/djsigaty/Desktop/backup” ‐‐delete “/Volumes/Sigastash/Ziglet1” “/Volumes/Ziglet1/”

Recommended modifiers

-a: Archive. This command is one purely of convenience, combining a number of other modifiers to the practical end of preserving everything about the copied files except for system-dependent features like hard links. To be more precise, -a is equivalent to -rlptgoD:

  • -r preserves directory structure recursively
  • -l preserves links between files
  • -p preserves permissions
  • -t preserves timestamps on the original file
  • -g preserved groups
  • -o preserves owner data
  • -D preserves device and special files

-b: Backup. This command is a failsafe, allowing you to preserve conflicted copies of files and files which would be deleted. After -b, a target directory must be specified, using ‐‐backup-dir=”[backup directory path]”. This will specify a directory in which rsync will preserve copies of any files which get removed during the process. You can see this in my formula; running that exact command will drop deleted files into a folder called “backup” on my desktop.

-v: Verbose. This modifier makes the command spell out what it’s doing while it’s doing it. I like getting as much information as possible, generally, and this can be an invaluable tool for diagnosing errors, should they occur (e.g. hanging on a corrupt file).

‐‐delete: This extra tag tells rsync to delete any files that exist in the target destination but not in the source (or, given the -b modifier, put them in a specified backup directory).

Additional modifiers

Here are a few more modifiers of rsync you might find useful.

‐‐NO-[option]: If you want to exclude one component of a combined modifier (like -a), this will allow you to do so.

-u: Update. If you’ve got up-to-date versions scattered between both your source and target, -u will let you keep the newer of the two, whichever it is.

-n: Dry run. Simulate the operation so you can make sure no errors will occur before committing. Great for your first time!

-z: Compress. For backing up massive amounts of data or using smaller drives, you can compress the data being transferred as part of the transferal process.

There are many more options (see a much more extensive list here), but these are the most useful for a tech-savvy photographer looking for a powerful, lightweight backup solution. Stop by the comments with any questions or to report your great success!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.