[conspire] Simple backup
rick at linuxmafia.com
Mon Oct 17 03:27:15 PDT 2005
I've been feeling more than usually like a chump who isn't taking his
own advice, in that backup of my main server has been broken for a
while, because of failed hardware. (Long story, not very interesting.)
Because I'd feel really stupid if I suffered massive data loss because
of (e.g.) hard drive failure, I finally found time today to...
o Do a full (yet dirt-simple) system backup, more-or-less the smart way, and
o Write down a recipe for that dirt-simple backup.
If you're like the typical PC user -- even, woe unto us, the typical
Linux-using PC user -- you've blown off the concept of backups, and are
whistling in the dark. Bad, bad, bad idea. Here's the recipe:
"Backup Scheme" on http://linuxmafia.com/kb/Admin/
I said "dirt-simple" because it's the sort of not-very-sophisticated,
seat-of-the-pants backup that can save your ass. All it took was 20
minutes and 1/2 GB of disk space on a nearby system, to give me much
greater peace of mind. Room for improvement? All over the place -- but
the sophisticated backup you never get around to has no value, while the
dirt-simple backup you _do_ is like gold.
People who attend CABAL meetings know that I have a standing joke that I
train consulting clients to refer to "restore systems" rather than
"backup systems", for reasons that should be obvious. In that spirit,
restore details are included. Obviously, the directories cited are for
_my server_: Your (e.g.) Linux workstation might well have its crown
jewels elsewhere. Take cum grano salis, to suit.
Text of the "recipe" follows. Adapt at will:
How to do a full backup and restore of linuxmafia.com
(Example cheatsheet with casual, full backup of a Debian GNU/Linux system.)
Backup -- execute these tasks:
fdisk -l /dev/sda > /root/partitions-sda-$(date -I) Partition map of SCSI HD a
fdisk -l /dev/sdb > /root/partitions-sdb-$(date -I) Partition map of SCSI HD b
dpkg --get-selections > /root/selections-$(date -I) Installed packages
Then, back up these directories and files, e.g., over rsync to a remote
system for safekeeping.
/root Root user's home directory (includes above files)
/etc System configuration files
/usr/lib/cgi-bin CGI scripts
/var/lib/mysql MySQL database files (dump if not queiscent)
/boot/grub/menu.lst GRUB bootloader configuration
/var/spool/exim4 Exim and SA-Exim internal files
/var/spool/news NNTP news spool for Leafnode
/var/spool/mail SMTP mail spool
/var/lib/mailman/lists Mailing list definitions for Mailman
/var/lib/mailman/archives Mailing list archives for Mailman
/usr/local Locally installed files and records
/var/www Public http, ftp, rsync tree
/home Non-root users' home trees
Part of the point of the above is that including all of the directories
that need backup is a non-trivial task, and requires some study of one's
If the above-cited system needed to be reloaded from backup, here is how
it would be restored:
Do a minimal Debian installation from trusted media, using partition
maps preserved above.
Using file selections-NNNN-NN-NN from above, do
dpkg --set-selections < selections-[date string]
apt-get -u dist-upgrade
Rebuild /etc with reference to /etc copy above, making sure you restore
users and groups to /etc/passwd, shadow, group, gshadow.
Copy other files back.
Rebuild or reinstall local packages.
Restart services. Check logfiles for errors.
More information about the conspire