Backups
I've recently had to think about the mechanics of making idiot-proof backups on Linux and OSX. The specific machine I'm backing up is a Linux host with a 40GB drive. Historically only about 10% of the drive has been used, and the user has an IMAP mailbox, so all the mail is safe already.
The smallest USB drive I could get was an Iomega 250GB for like $60. Since the drive is 6x bigger than the drive that's being backed up, I've decided to make a multi-snapshot backup set using rsync. I have rsync propagating deletions, so this is in the event the user realizes that they've deleted something they needed, but it was like 2 weeks ago, they can go rooting for it.
The basic idea is to test that the drive is mounted correctly. Then to rotate all the snapshot directories one step, then mv the oldest snapshot into position to receive the new sync update. This way I'm never copying anything, and I'm never resync'ing the entire directory structure.
Then I pop a dialog with the results of rsync, or a dialog saying the drive isn't attached correctly.
Here's the script I'm using:
user@linux-fq6k:~/bin> cat laptopbackup.sh
#! /bin/bash
## Test if drive is attached
stat=`stat -t /media/Iomega\ HDD | awk '{print $1}' | sed 's/\///g'`
if [ $stat = mediaIomega ]
then
## Rotate Snapshot Directories
mv /media/Iomega\ HDD/backup4 /media/Iomega\ HDD/backup-tmp
mv /media/Iomega\ HDD/backup3 /media/Iomega\ HDD/backup4
mv /media/Iomega\ HDD/backup2 /media/Iomega\ HDD/backup3
mv /media/Iomega\ HDD/backup1 /media/Iomega\ HDD/backup2
mv /media/Iomega\ HDD/backup0 /media/Iomega\ HDD/backup1
mv /media/Iomega\ HDD/backup-tmp /media/Iomega\ HDD/backup0
## Sync Backup
rsync -vaE --delete --exclude=".beagle" /home/user/ /media/Iomega\
HDD//backup0/home/user/ > ~/.backup.log
kdialog --title "Backup Status" --textbox ~/.backup.log 1000 300
else
echo "Drive Not Attached - Backup Failed" > ~/.backup.log
kdialog --title "Backup Status" --textbox ~/.backup.log 1000 300
fi
I need to work on the exclusion lists because there's plenty of cache stuff I don't care about, and I'm going to add /etc/ into the sync as well, but this should capture basically all the stuff I want.
I'm going to set up a similar system on my primary Mac, in that case I'll just use cron and skip the whole dialog box thing, then swap drives every week with a remote location in case my house burns down.
- xrayspx's blog
- Log in to post comments
- 9561 reads
Comments
Back-ups
"Idiot-proof"...yeah, I knew who you meant.
Re: Back-ups
It isn't completely idiot-proof, it still relies on someone plugging the drive in and hitting the button, of course. But it is one button backup, you click the icon, it will tell you if it can't write to the external drive, then it will sync your backup snapshot.