Category: Scripts

Simple, Fast, iTunes Backup

January 10th, 2008 Permalink

Our iTunes library at home is on the large side (250 GB) and I am always looking for a better way to back it up. The main library lives on an external hard drive hanging off of a G5 iMac, and the backup drive is an external drive that gets a copy of the data […]

Our iTunes library at home is on the large side (250 GB) and I am always looking for a better way to back it up. The main library lives on an external hard drive hanging off of a G5 iMac, and the backup drive is an external drive that gets a copy of the data and stays at work most of the time.

I recently upgraded the G5 to Leopard and replaced the main external drive with a 750GB Seagate drive. As part of this swap, I wanted to find a better backup solution. I was using software that came with the LaCie drive, SilverKeeper. This worked alright, but it was quite ugly, and seemed a little bit clunky. I use SuperDuper to do full backups of my computers, but it didn’t seem to be able to backup just a single folder. I spent some time searching for a simple, free backup program, but couldn’t find anything that did what I wanted.

Then I remembered that under all that pretty GUI is the muscle of Unix. Why not just write a simple shell script and use rsync to do the backup?

Here is the script:


#!/bin/bash # Back up files from SRC to DEST # The hidden .DS_Store files will be excluded # The iTunes library will also be backed up #SRC should point to the folder you want to back up SRC="/Volumes/Media/iTunes Music" # DEST should point to the location you want to put the files DEST="/Volumes/My Book" # LIBRARY is the location of your iTunes music library file. # In most cases, this does not need to be changed LIBRARY="$HOME/Music/iTunes" # This line backs up the media drive rsync -av --exclude '.DS_Store' "$SRC" "$DEST" # This line backs up the iTunes Library files rsync -av --exclude '.DS_Store' "$LIBRARY" "$DEST/iTunes Library"

To use the script, copy and paste into any text editor. You will need to modify the SRC and DEST variables to reflect the source and destination for your backup. Once you have modified the script, save it with a .command extension. Then, when you want to back up your music, just double click the file. The Terminal program will launch, and the backup commands will run.

If you store your music in the default location in your home directory, you will only need one rsync command. Just make the value of SRC “$HOME/Music/iTunes”, and comment out the second rsync command by putting a # at the beginning of the line.

This technique can be used to back up any directory. I have found that rsync is reliable and fast. If you have any questions about this script, leave a comment or send me an email, and I’ll try to help.