Ok, so a few days ago I wanted to sync some photos between by laptop and my desktop. My desktop has my entire photo collection and I have a subset of that on my laptop. I frequently sync directories between the two using rsync. The desktop doubles as a backup, the files are on a RAID1 array for redundancy -- of course that isn't enough to be safe, and yes, I found out.
The directory structure is very simple, I've set it up as
with yyyy the year, mm the month and dd the day of the month.
After having done some editing in the current month on my laptop, I wanted to sync it to my desktop.
I have a small script that uses rsync to synchronize the current working directory from my laptop to my desktop. I had deleted some bad photo's and obviously wanted them removed from the desktop as well. So I gave the script the --delete flag, which it handed over to rsync.
I ran the script and was greeted by screenfulls of lines saying deleted xxx or yyy. Hmm, I didn't delete that much pictures. I glance at the files that are being deleted, hmm, wait a minute, those aren't the right ... AAAAAH!
FUUUUUCK! I'm bashing CTRL-C for my life here! Finally it kills itself and gives me a shell prompt. I look at the current working directory:
That should of course have been
And as I said, I don't have a full mirror of all the photos on my laptop (not enough hard disk space there), so it started pruning all the older ones from my desktop. Ouch.
I've shut down the desktop asap and haven't booted it since. I'm probably going to try my luck with extundelete after the exams. Fingers crossed.
TL;DR Be careful with the --delete flag in rsync. It will fuck you up sooner or later!