16 Aug 2009

Sync your iPhoto library with rsync

Posted on August 16, 2009

Today I wanted to sync my iPhoto (‘08) library to my NAS because I wanted a backup of my photos which I can make accessible on the internet through my NAS. This just looked like a simple task for rsync and I started to look where iPhoto stores my photos.

The first thing I realized was that the Library folder contained a folder named Originals and another one named Modified. The folder Originals contains all photos you have imported into iPhoto. The folder Modified contains only the photos which you have modified through iPhoto.

This means that I would have to merge the modified photos with the originals to have the correct version of every photo in the destination folder. After thinking about the problem and reading the rsync man page I came up with the following shell script:

SRC="/Users/andreas/Pictures/iPhoto Library"

cd "$SRC"

find ./Modified -type f -print | sed 's!./Modified!!' > $EXCLUDE
rsync -azP --exclude-from="$EXCLUDE" --delete "$SRC/Originals/" "$DST"
rsync -azP "$SRC/Modified/" "$DST"


Download the script here

The script first generates an exclusion list containing all modified files. Then the originals are synced to the destination folder using the exclusion list. After that the missing modified photos get synced to the destination. And that’s it, you have a folder containing only the latest version of your photos.

Depending on the size of your library The first run will take a while. But due to rsync the following syncs will be very fast.

I don’t know if this script will work with another iPhoto version than iPhoto’08. I also must note that I used rsync version 3.0.6 which is not the original version which comes with Leopard. if you try the script with another version please use the –dry-run option! If it works please leave a comment.