Be Careful With rsync –delete

Filed under: Uncategorized. Tags: , ,

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.

Comments

6 Responses to “Be Careful With rsync –delete”

  1. Sami Khan on October 3rd, 2006 6:05 pm

    I love the OOPs tag. I should make a copy of that tag for my site. I have nuked gigs of data (fortunately it was just entertainment junk)… I am still bad at my backup practices :(

  2. Micheal J on October 3rd, 2006 8:08 pm

    It should be noted that rsync doesn’t support Resource forks, so if you’re using rsync to back up, say Quicken data? It’s useless and leaves a crippled backup file. You need to install the Dev tool and use CpMac or use ditto. (Or even better SuperDuper depending on the setup).

    From what I understand rsync should support resource forks in Leopard, but I’m not entirely sure on this.

  3. dnorman on October 3rd, 2006 9:06 pm

    Resource forks? Does anyone still use those? All the files I use are either text or binary. No need for those old school forks…

  4. Ryan Collins on October 5th, 2006 4:25 pm

    Rsync under Tiger (10.4) supports resources forks. Actually, IIRC all of the command line tools (cp, mv, rsync, etc) are resource fork aware.

  5. Joachim Bengtsson on November 4th, 2006 1:48 am

    You have to give rsync the -E flag to make it resource fork aware.

  6. Joachim Bengtsson on November 4th, 2006 1:48 am

    You have to give rsync the -E flag to make it resource fork aware.

Leave a Reply

You must be logged in to post a comment.

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.5 Canada License.