Backup (or backing up) your iTunes & iPhoto databases

So you spend hours importing music and photos into iTunes and iPhoto, painstakingly crafting those playlists, ratings, smart albums etc. You entrust all that hard work into proprietary, closed file formats (the iApp databases), whose applications are known to have flaws and can crash, destroying all your hard work; wouldn't it be a horror if you lost it all? "But I back up!" I hear you cry; sure, don't we all, but how often do you run that backup? Once a month? Once a week if you're keen? Wouldn't it still be a pain to lose what you did just yesterday? Here I present a solution - a script that'll back up just your iTunes and iPhoto databases (and Camino bookmarks, natch) as often as you choose.

Now those of you who're using Time Machine (good luck with that ;o) will be sitting pretty, but what about those of us with older versions of OS X and/or no desire to get into Time Machine? This howto is for us.


  1. Download the script from Resources above, put it somewhere sensible (how about ~/Documents/Scripts) and make it executable:
    • Open Terminal
    • cd ~/Documents/Scripts
    • chmod 755
  2. Create a folder for the script to put the backups into - it needs to be somewhere within your home folder (I use ~/iBackups).
  3. Open the script in your favourite text editor. You need to configure the variables that store the folder locations as follows:
    • HomeDir - replace XXXX with the name of your home folder (whatever your short username is).
    • BupPath - I use a folder called 'iBackups', change this to match the folder you created in step 2 above.
    • iPhotoPath, iTunesPath - confirm that these are correct for your machine.
    • CaminoPath - confirm that this is correct for your machine. If you don't use Camino, delete "${CaminoPath}/bookmarks.plist" from the line beginnning tar lower down in the script. If you don't, it will run just fine and back up the other files but will complain that it has failed to complete the backup.
  4. Test it:
    • Open Terminal.
    • cd ~/Documents/Scripts
    • ./
  5. If that worked, all that's left is to have the script run automatically and regularly. For this, I use the cron daemon that's built into OS X, combined with an install of trusty Anacron, which makes sure that tasks run even if they were scheduled whilst your machine was switched off.
    • Install Anacron.
    • Open Terminal.
    • cd /etc
    • sudo pico daily.local (assuming you want to back up every day, else use weekly.local or monthly.local)
    • Add this: sh /Users/<your short username>/Scripts/
    • Type Ctrl-X and follow the prompts to save and exit.
  6. You're done. The script deletes backups more than one month old, so it won't consume disk space indefinitely.