A cautionary tale….
Earlier this week I was busy rebuilding an old machine to use as a dedicated writing machine.
I going to blog all about that at TheFridayBlog (my writing blog) tomorrow!
One thing that I won't mention there is the minor setback that occurred due to my stupidity and lack of thought.
The problem was rsync!
I decided (quite rightly) that it would be rather sensible to back up the writing machine not only to gmail (my normal process) and to an external USB drive (I just happened to have a spare one available) but also to my server.
Rather than write a backup script from scratch I decided to use an old one and just change the locations.
The edited script (this is just an extract – the bit that did the damage!) that I used was as follows….
# And then back Elgar up to Mozart….
rsync -av –progress –delete –log-file=/home/keckstein/Backup/$(date +%d%m%Y)_Elgar_backup.log /home/keckstein/ /media/Mozart
And what's wrong with that, I hear you ask?
Yes, it looked OK to me at first glance.
There are (as I later found to my cost) two problems…
1). I should have been rsyncing the data to it's own directory on Mozart (rather than the root of the share) and
2). I really should have thought harder about that –delete parameter!
Normally I like to use the –delete parameter for disk to disc backup copy jobs.
What happens is this; if you delete a file on the source drive (the drive that you are backing up), rsync will also delete that file from the destination drive (the drive you are backing up to.)
All well and good. The destination drive is a mirror copy of the source drive. That's what we want, isn't it?
What happened the first time I ran the backup script (it contained a lot more than just that one line but, that one line was more than enough to cause me a whole pile of grief!) was that the files were copied from Chatwin to Mozart – no problem there.
Then rsync deleted every file on Mozart that didn't exist on Chatwin!
Oops!
Read more...http://www.kmeckstein.com/linux/a-cautionary-tale/
Don
No comments:
Post a Comment