Rsync: Backing up Music Purchased from iTunes Music Store

Obviously, backing up tracks purchased from iTunes Music Store on a regular basis is a very good idea (along with anything else you really don’t want to lose).

I use an external hard drive for backups. I also like to burn all of my purchased music to a piece of optical media whenever I purchase new tracks (about once a month).

Now, I don’t really need to backup all of my ripped CDs. The CDs are the backup. Given that Apple has consistent history of releasing better quality audio encoders fairly regularly, I’ll need to re-encode my CD collection every couple of years anyway.

The purchased music is interleaved with non-purchased music. To back it up, I use rsync to copy the purchased music and only the purchased music to the external hard drive. From there, it is trivial to burn the copied files to CD or DVD.

The rsync command to synchronize the purchased music and only the purchased music is a bit tricky because rsync’s include/exclude options are, uh, subtle.

Of note (yes, that is all one single command):

rsync --block-size 32000 -e ssh \
    --progress --partial -a --include '*/' --include '*.m4p' \
    --exclude '*' \
    'orange.local.:/Volumes/LargeData/Master\ Music\ Library/' \
    /Volumes/ExterData/MusicBackup/Purchased\ Music
  • It works on any system that can resolve the name ‘orange.local.’ (the name of the machine with the music library) including on that machine itself. rsync is that smart.
  • The –block-size option increases the CRC block size to 32,000 bytes. This is several orders of magnitude larger than the default. Larger block sizes are much more efficient for large files.
  • –progress shows percentage transferred for each file
  • –partial will not delete files on the local end that aren’t fully transferred. Very useful if you happen to be backing up across a slow or intermittent link or you simply want to hit ctrl-c in the middle and finish later.
  • -a is a catch-all option that enables a bunch of other options that are fairly optimal for archival purposes
  • The order of the –include and –exclude options are critical. The first includes “all directories”, the second grabs all purchased music, and the third excludes everything not selected by the first two. Remove the first –include and rsync excludes the top level directory and does not recurse at all.
  • Annoyance: you’ll end up with empty folders for all of the non-purchased content. Doesn’t bother me that much, but I wish rsync had a “don’t create empty folders” option.


Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>