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 +%F) Partition map of SCSI HD a
fdisk -l /dev/sdb > /root/partitions-sdb-$(date +%F) Partition map of SCSI HD b
fdisk -l /dev/sdc > /root/partitions-sdc-$(date +%F) Partition map of SCSI HD c
dpkg --get-selections "*" > /root/selections-$(date +%F) Installed packages
tar cvzf /root/etc-$(date +%F).tar.gz /etc
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 (omit PHP binaries) /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/mail SMTP mail spool /var/lib/mailman/archives Mailing list archives for Mailman /var/lib/mailman/data Mailing list state and other data /var/lib/mailman/lists Mailing list definitions for Mailman /var/lib/mailman/nntp Mailing list NNTP gateway data /var/lib/mailman/qfiles Mailing list in-process data /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 system.
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.
mkdir /usr/local/opt cd / rmdir /opt ln -s /usr/local/opt
Prune the contents of (a copy of) file selections-NNNN-NN-NN from above to remove (1) libs (which will get fetched if needed as dependencies and (2) packages you're pretty sure upon examination you no longer need, then, do
dpkg --set-selections < selections-[date string] apt-get dselect-upgradeThis may recall some interative pruning and correcting of the "selections-NNNN-NN-NN" file, as it's quite possible (especially if you're using a later Debian base version as the migration target) that some formerly used packages no longer exist / have different names. Don't worry too much if you can't find a package's new name; more likely than not, it will be found as a dependency anyway. However, make a note of anything that appears unfindable, for later checking.
Rebuild /etc with reference to /etc copy above, making sure you restore users and groups to /etc/passwd, shadow, group, gshadow. For linuxmafia.com, build/configure leafnode, configure Mailman's nntp service, enable related cronjobs.
2006-05 linuxmafia.com network services:
- apache 1.3.x (or migrate to 2.x)
- leafnode (under inetd)
- inetd (leafnode-only)
- spfd (package spf-tools-perl)
- (mysqld, local)
- (mysql-ndb, local)
Copy other files back.
Rebuild or reinstall local packages.
2006-05 local packages on linuxmafia.com:
- libip-country-perl_2.20-1_all.deb (built from IP::Country by dh-make-perl),
- libtext-csv-xs-perl_0.23-1_i386.deb (built from Text::CSV_XS by dh-make-perl -- but now available in "lenny" as package libtext-csv-perl),
- perlhoo-linuxmafia-1.21.tar.gz, and
One-off scripts and utilities:
- convert.py (Rick's)
- cr2null (just this: cat $1 | tr -d "\r")
- dumpdmi (Chip Salzenberg's)
- haiku (Danny O'Brien's)
- largest20 (Rick's, copying and slightly tweaking Ben Okopnik's script)
- lowercase (Rick's)
- newmonth.py (Deirdre's, for autobale)
- pico (symlink to /bin/nano)
- pine (wrapper script for mutt)
- rant (Karsten Self's)
- rot13 (just this: tr 'a-zA-Z' 'n-za-mN-ZA-M')
- tidyloop (Ben Okopnik's)
- c06d (cmudict.0.6, for haiku)
Restart services. Check logfiles for errors.