introductioninstalling redhatunix commandsediting filesssh
sitemapapacheftptcp/ipmisc-notesresources

creating a disaster recovery backup

first you need to understand how a hard drive and it's partitions relate to your server installation
When you boot your pc, it checks to see if there is boot information in the master boot record of the drive. The master boot record tells the pc hardware to look at (usually, but not always) the first partition on the drive and try to load the software that it finds (that would be the operating system). Otherwise, it will skip to the first sector of the first partition and try looking there. If no boot information is found in either location, your pc will not start up.

With linux you need to have at least two partitions. One for the root of your filesystem "/", and one partition for swap space (virtual memory). I usually create several partitions when I build a server. This is to seperate key componenets of my server so something like a log file that has gotten too big will not fill up the hard drive and crash the server. Instead it would fill up the partition that contains the log file and stop the log from being able to grow until the issue is fixed not affecting the server as a whole. When planning a server installation always keep maximum uptime in mind.

So for my example, I have a drive that has 8 partitions. See below chart for details.

So enough intro, here is what needs to be done. All of the partitions need to be backed up. A boot floppy needs to be created and you need to save a few config files for reference as to how to put together a server from the pieces of your backup.

record some information from the drive you wish to backup
At a console logged in as root issue the following commands and copy the output of those commands to a text file using "copy and paste". Save the file for future reference.

get detailed partition info with fdisk
# fdisk /dev/hda
# p
# q
see output
The above command will enter the fdisk program looking at /dev/hda (drive #1). Once inside the fdisk program the "p" command prints the partition map. Then a "q" will quit the fdisk program.

get the contents of /etc/fstab
# less /etc/fstab
see output

see what partitions are mounted and where
# mount
see output

similar to mount but easier to read
# df -h
see output

create a boot floppy
You will need this to boot a restored backup the first time.

create the backup
Remove the hard drive from linux box #1. Install it on linux box #2 as a slave to the primary drive.
Boot up linux box # 2.

create mount points for the drive you wish to copy
# cd /
# mkdir copy
# cd copy
# mkdir 1 2 5 6 7 8
Notice that 3 and 4 are not in the above command. That is because partition 3 (swap) and 4 (extended) contain no files.

mount the partitions to be copied
# mount /dev/hdb1 1
# mount /dev/hdb2 2
# mount /dev/hdb5 5
# mount /dev/hdb6 6
# mount /dev/hdb7 7
# mount /dev/hdb8 8

now if you look inside /copy/1 you should see the contents of partition 1 and so on.

create compressed archives of the partitions that you just mounted
# cd 1
# tar -czf ../partition1.tgz *
# cd ../2
# tar -czf ../partition2.tgz *
# cd ../5
# tar -czf ../partition5.tgz *
# cd ../6
# tar -czf ../partition6.tgz *
# cd ../7
# tar -czf ../partition7.tgz *
# cd ../8
# tar -czf ../partition8.tgz *
This will create compressed (tar & gzip'd) archives of the corresponding partitions.

make an image of the boot floppy that you created
# cat /dev/fd0 > server_boot_floppy.img

now prep for burning a cd rom of your backup
What you need to do is put the boot floppy image all of the .tgz files and the screen output copies that you made on a cd. So transfer all of the files to a machine that you can burn a cd from and burn a copy.

now see how to restore form the backup you just created