backuporama
Sean asks “what's your backup strategy?”
Since I've been meaning to write this since my last post on backups, I'll do my part to spread the meme.
Like Sean, I run Ubuntu on my T42p. And like Sean, I keep as much stuff as I possibly can checked into source code control systems at work, on Java.net, on Sourceforge, etc. If I'm writing code or prose, I want it checked in somewhere. I run a Subversion repository on my laptop so even private stuff is “checked in”. (A local repository doesn't save me from a disk disaster, but the real risk on a day-to-day basis isn't hardware failure, it's human stupidity. Mine.)
On a roughly monthly basis, I connect an external drive and run the following script:
#!/bin/bash
BROOT=/media/usbdisk/Backup/ndw
DATE=`date "+%Y-%m-%d"`
if [ ! -d $BROOT ]; then
echo "No backup directory: $BROOT"
exit 1;
fi
echo "Stop mysql and hit return..."
read $x
echo "Backing up /var/lib/mysql/"
rsync -a --delete /var/lib/mysql/ $BROOT/var/lib/mysql/
echo "Ok, you can start mysql again..."
echo "Backing up /etc/"
rsync -a --delete /etc/ $BROOT/etc/
echo "Backing up /opt/"
rsync -a --delete /opt/ $BROOT/opt/
echo "Backing up /home/"
rsync -a --delete \
--exclude ndw/Mail/ \
--exclude home/ndw/Desktop/ \
--exclude home/ndw/.Trash/ \
--exclude home/ndw/.mozilla/firefox/926iwrha.default/Cache/ \
--exclude home/ndw/.mozilla/firefox/oijtdfv2.xproc/Cache/ \
--exclude home/ndw/tmp/ \
--exclude home/ndw/scratch/ \
--exclude home/ndw/.thumbnails/ \
/home/ $BROOT/home/
echo "(Mail will be done later...)"
echo "Backing up /share/"
rsync -a --delete /share/ $BROOT/share/
echo "Backing up /root/"
rsync -a --delete /root/ $BROOT/root/
echo "Backing up /usr/local/"
rsync -a --delete /usr/local/ $BROOT/usr/local/
echo "Backing up /home/ndw/Mail/"
cd /home/ndw
tar cf - .news* .gnus* Mail | gzip > ${BROOT}-mail.$DATE.tar.gz
echo "Compressing backup..."
cd $BROOT
cd ..
tar cf - ndw | gzip > ndw.$DATE.tar.gz
echo "Done"
The MySQL backup captures my DSPAM training database. I ask first because I have to stop my periodic mail collection script so that it doesn't run while MySQL is down. (I suppose I could fix that, but it hasn't been a big deal.)
I backup /etc
, /opt
,
/home
, /share
(where I keep
most things that aren't in my home directory), /root
,
and /usr/local
. Mail is backed up in a slightly
different way because
it consists of so many tiny little files.
I keep photographs and music under /share
,
so that gets backed up with everything else. But I also copy those files
separately onto backups of their own.
Using
rsyncThe value of rsync with a local disk may be negligible, but a slightly
modified version of this script used to run backups across my network before
I had a USB2 enclosure.
means that I don't copy over a bunch of stuff
that hasn't changed (like huge parts of /share
and
/usr/local
). But it also means that I only have
one backup. That's why I added the last steps, to make a dated, compressed
archive. Being able to look a little further back in time has saved my
butt more than once.
I don't use Windows, but Deb does. I backup her laptop by smbmounting it and copying the relevant bits onto my laptop, where it gets backed up as per above.
Comments
I just learned about rsync.net today. I haven't tried it yet, but it's a service from my co-location provider, and they're very professional.
Hi Norman, you might be interested in a couple of backup applications. rdiff-backup is like rsync but stores incremental history. I have about a year's worth of daily backups in it. Box Backup does encrypted compressed differential streaming backups over your internet connection. Neither has a GUI right now, but I'm developing one for Box Backup (http://boxi.sourceforge.net).
Also, you don't need to shut down MySQL to back it up. Just run mysqldump --databases --lock-tables, and pipe the output to a file.
Cheers, Chris.