Sync your iPhoto library with rsync

Written 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"
DST="codestore:/volume1/photo"
TMP=~/tmp
EXCLUDE="$TMP/iphoto.exclude"

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"

rm "$EXCLUDE"

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.

thomasy
May 10, 2010 - 06:43

I love the idea of the script you created. However, being a nube with rsync scripting I can't get it to work with iPhoto '09. Have you updated the script for the latest version?

Reply to thomasy
Andreas
May 10, 2010 - 09:04

Sorry, I don't have iPhoto 09 yet so I don't know what needs to be changed to get it work.

jb
December 29, 2009 - 08:41

another thought for a more Mac centric approach.

Was looking at rsync, but there was an element of scripting which I always wonder will it work reliably forever and can it notify me when cron stops running.

My set up. MacBook (where I sync and manage iPhoto), MacMini (Always on Mainly for kids & DVD ripping, eyeTV in the other room), PS3 Main TV with Play TV (Upscaling and performance better than MACMini as a media center), ReadyNAS backups and DVD streaming DNLA.

Solution: time machine back up to ReadyNAS (Doing this anyway), MAC Mini mounts time machine back up (Which is a symbolically linked dir strcuture), pointing at latest TimeMachine Image (Latest directory), Media Link on the MacMini (DNLA streaming support for iPhoto, is pointed at the time machine mount), PS3 Streams Content from iPhoto from MacMini.

Seems to work, complex sounding, however no script and my back up job serves dual purpose and I am safe in the knowledge that I pay attention to time machine back up and get alerts if broken. Rsync needs to rescan all files, where as Time machine uses System hooks to detect change. If you do not use time machine you can just use it for iPhoto directory to cut down the sync size.

tshack
December 07, 2009 - 19:46

Thanks for this. Good work!

Leave a Comment



?
?

Powered by TalkBack