Pages

Sunday, March 7, 2010

Thankful for backups

I've a read a saying that is quite true
There are two types of people using computers; those that back up regularly and those who will


It's a fact of life that hard drives fail. Not a matter of if, but rather when. After my second hard drive failure - I'm a little slow, it took 2 - many years ago, I became a person that makes disaster recovery discs, and regular file backups. Once a method is developed and put in action, hard drive failures are easier to deal with.

Having suffered 2 hard drive failures in 2 weeks allowed me to put my backup practices to the test. These were not freak hard drive failures, nor anything to make me need to investigate other system components/applications for the cause. The hard drives were each at least 3 years old, and consider the usage I got from them to be more than adequate.

Regular file and data backups are easy enough to do. I tend to burn everything to 2 sets of optical discs, and use an online service (DropBox) as well. Our entire MythTV movie collection is backed up to DVDs. Glancing at the media case, I'd estimate +/- 150 DVDs with ~4 movies each. Granted we still own the original DVDs and could always just re-rip and re-encode, but that's months and months worth of work. 100 high quality Taiyo Yuden DVDs cost less than $30. Well worth the money.

The part of recovering from a hard drive failure that takes the most amount of time and causes the highest level of frustration is the operating system install itself. We've put oodles of time finding and implementing tweaks, customizing settings, hunting down specific applications to do specific tasks. When starting over from scratch we're lucky to remember everything we had done before. More times than not, that website with the fantastic howto is now gone. Archive.org for some reason doesn't have this website in their database. If we even remembered to book mark it in the first place.

This is why I make disaster recovery sets for all of our systems. There's no special tools, applications, nor proprietary formats. If you have the Slackware installation CD/DVD you have everything you need. Best of all, the archive can be read by any Linux Distro, and even Windows if the need arises.

Here's a quick example of how I make our disaster recovery images. Which just recently have been verified to work.

Boot Slackware installation CD/DVD
If you don't already own Slackware, buy it, download it, or make your own.
Press enter to boot the default kernel, log in as root. You have to create an archive, and save it some where. Another hard drive, cifs/nfs share, ftp ... I export my archives to our file server through cifs. To bring up networking type dhcpcd eth0, then verify you have an IP with ifconfig.

Mount remote share and local hard drive
I'm using cifs
mount -o user=user,pass=supersecret //fileserver/backups /var/mount

Mount the partition you want backed up
mount /dev/sda1 /mnt


Create disaster recovery archive
There are other compression schemes besides gzip that result in smaller file sizes. Size saved : time taken does not equal out to be worth while unless you really need to save space. A full Slackware install of ~4.6GiB compresses to ~1.7GiB with gzip, and ~1.2GiB with xz and p7zip. I have timed our backups to be ~15minutes with gzip, and 45+minutes with p7zip and xz.

Create the actual backup archive
cd /mnt
tar -czvpf /var/mount/system.backup.tar.gz \
--exclude=proc --exclude=lost+found --exclude=sys .

If you are going to create your archive on the same drive, be sure to add --exclude=system.backup.tar.gz or tar will attempt to add your backup archive to your backup archive.

And that's it. Your complete installation is now saved in a single portable archive. Don't forget to burn it to disc for keeping.

Restore from disaster recovery archive
I create a DVD that includes the backup archive, and parts of Slackware to make a single bootable disc. This is quite easy to do.
Make a directory ~/slackboot. In that directory place the entire contents of isolinux/ and kernels/ from you favorite Slackware mirror (or copy them from your DVD) along with your backup archive.
isolinux/
kernels/
system.backup.tar.gz

Make the iso image by following the README.TXT inside isolinux/ and boot from it.

Press enter to boot the default kernel, log in as root. Partition and format your new hard drive, and mount it mount /dev/sda1 /mnt Mount the DVD containing your backup mount /dev/sr0 /var/mount
Restore your system
tar -xzvpf /var/mount/backup.tar.gz -C /mnt

Create missing directories
mkdir /mnt/{proc,sys}
(lost+found was created when you formated)
Don't forget to reinstall lilo.
lilo -b /dev/sda -C /mnt/etc/lilo.conf

Of course, adjust to your system.

You can also chroot into your system to adjust things - like /etc/fstab if you change file systems or mount points.
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
chroot /mnt

No comments:

Post a Comment

Post a Comment