How To Back Up Your iTunes Music With rsync On Mac OS X

, , , ,

Update: This is confirmed as working on 10.5 (Leopard) & 10.6 (Snow Leopard).

The average Mac user probably doesn’t mess much with the powerful (but almost entirely un-friendly) Unix underpinnings of OS X, nor do they generally need to. Sometimes, though, the tools provided in the shell are so useful, that it’s worth taking the plunge. Keeping a good backup of your iTunes music folder is, in my opinion, one of these times. To do it, we’re going to use one single line of code, and a unix command-line tool that is built-in to OS X: rsync.

This tutorial makes a couple of assumptions. Firstly, this might work on versions of OS X before 10.4 Tiger. I haven’t tested it, so I really don’t know. So we’re going to assume you’re using 10.4 or newer. Secondly, I’m going to pretend that you’ve kept iTunes at it’s default setting, and it is keeping all of your music files where it usually does (in /Users/yourusername/Music/iTunes Music). Third, I’m going to proceed as if you want to back up your music from one drive to a second drive. It doesn’t matter if it’s external or internal, beefy firewire enclosure or USB thumbstick. So long as it has enough space. For simplicity sake, I’m going to call them Main Drive and Backup Drive. Let’s go.

Step 1: Set Up Your Directory

The first thing we need to do is make a directory on your Backup Drive to keep your backed-up music in. Open the Finder, and click on your backup drive in the sources list, on the left. The sources list looks something like this:

Sources List in 10.4

Click on whichever drive you want to use as a backup, and create a new folder there (command+shift+n, or click File and New Folder in the Finder menu). Call it “Music Backup”.

Step 2: The Cool Stuff

Now we’re going to use the Terminal. Open the Finder, and navigate to Applications -> Utilities and then double-click the Terminal application. It’ll open up and give you a nice blank screen. I’m going to show you the command we’ll be using, and then I’m going to explain it. It won’t take long. Here’s the command:

rsync -rvv /Users/yourusername/Music/iTunes /Volumes/Backup\ Drive/Music/

We’re calling the command rsync, here, a very quick and powerful synchronization tool. The -rvv tells rsync to recursively go through directories, and be very verbose. Very verbose means it’s going to tells us what it’s doing for every single file it goes through, so we can make sure it’s running smoothly this first time. The next time you run this, you can safely omit the vv part without worry.

Here’s how we build the command: In your terminal, type in rsync -rvv. The space after -rvv is important. Now, open up your Finder window, and click on the Music icon in the lower left. This will bring you to your music folder. There should be a folder here called iTunes. Click on the iTunes folder, and drag it on top of your terminal window, and release. OS X is so clever that it automatically copies the directory’s path into the terminal window for you. In your terminal window, put a space after the directory name that’s just been added, then, using the Finder again, navigate to the Music Backup folder we made in step one, and click and drag it onto the terminal window in the same way. It should, again, look something like this:

rsync -rvv /Users/yourusername/Music/iTunes /Volumes/Backup\ Drive/Music/

Take a second look to make sure your terminal looks like that, and then hit he return key. If it works, you’ll see rsync dumping it’s output onto the screen very quickly, and you probably won’t be able to read it. If you’ve got a lot of music, this could take many minutes. A beer may be in order. When it’s done, it will say something like this, and stop scrolling:

sent 5743531756 bytes received 11640 bytes 15976476.76 bytes/sec

total size is 61611466477 speedup is 10.73

What the actual numbers say isn’t important for our purposes. That just means it’s done. To make sure everything worked out okay, you can open your Music Backup folder in the finder. It should have all sorts of stuff in it, now. If all went well, your music is backed up, and you can close the terminal application.

That’s It

Yep. Simple, eh? The coolest part is, each time you run it from now on, it only copies the files that have been changed, drastically reducing the time it takes to back things up. rsync also has the capability to back things up from remote servers (like a web site, or another computer of yours), which you can learn all about in the documentation. For now, though, you can just enjoy the security of knowing that the odds of losing your entire David Bowie collection are effectively halved.

Hello There

My name is Phil Nelson and I make beautiful objects for a troubled world. I'm a designer / developer / writer / director / editor / narrator at Occipital.

Stuff I Make

More To See and Read

Browse the Archives

Hey. What're you doing all the way down here? You get lost? Just looking around? Cool. I like you.