Be Careful With rsync --delete


I've been using an rsync-based script to backup my iPhoto library to another computer, just in case my Powerbook blows up or something, so I don't lose every photo I've taken for the last 4 years. It's worked flawlessly, run every now and then from home, to squirt changes in my Pictures directory to my desktop at work, where I further back it up on an external drive using another rsync script.

But, now that I've added Aperture to my work desktop, the script I had been using became suddenly quite dangerous. As in, destructively dangerous. And I hadn't thought to check out the script in awhile.

So, I ran it last night. It faithfully chugged through my 'book's ~/Pictures directory, so I walked away as it started working.

Then, late last night I did a quick scroll through the rsync log, and to my horror found a whole bunch of stuff like "Deleting: ~/Pictures/Aperture Library.aplibrary/..."

Holy. Crap.

I'd accidentally told my computer to nuke my Aperture library on the work desktop.

So, I cracked open the "rsyncpics" script, and lo and behold, I'd left in the "--delete" flag. Which wasn't a problem - it was actually desired - when I was only using iPhoto. But since Aperture isn't on the Powerbook, the "--delete" flag told rsync to nuke anything on the desktop that isn't on the powerbook. Like the Aperture library. Doh.

Thankfully, I also periodically backup my work desktop's home directory to an external drive, so had a slightly out of date version of the Aperture library which I could just copy back into place. But it was missing everything after Ken Ryba's session from a week ago. I'd copied the best of the "Campus Tour" photos to my home iPhoto library, so it's not fatal, but a good lesson learned.

The moral of the story is: be careful with rsync, especially when using --delete. I've learned my lesson, and have resurrected most of the lost photos. I've also added an Aperture Vault on the external drive. They offer these backup tools, so why not use them?

Update: Between the various locations I'd copied files, and a healthy application of the awesome Flickr Backup utility, all photos worth saving have been restored. Whew.


backup  rsync  oops 

See Also

comments powered by Disqus