introductioninstalling redhatunix commandsediting filesssh
sitemapapacheftptcp/ipmisc-notesresources

restoring a bootable server drive from a backup copy

Now that you have a backup of your server, test your backup by restoring it to a drive and booting up from that drive. On a pc running linux perform the following tasks.

Connect a drive that you will restore the backup copy to and boot the pc.

Open fdisk and match the screenshot of the fdisk partition map that you copied from the original server.
# fdisk /dev/hdb < assuming that you connected the drive as a slave to the primary master.

once you have finished creating your partitions you need to format them
# mkfs.ext2 /dev/hdb1
# mkfs.ext2 /dev/hdb2
# mkswap /dev/hdb3
# mkfs.ext2 /dev/hdb5
# mkfs.ext2 /dev/hdb6
# mkfs.ext2 /dev/hdb7
# mkfs.ext2 /dev/hdb8

now you need to tune the formatted partitions
# tune2fs -j /dev/hdb1
# tune2fs -j /dev/hdb2
# tune2fs -j /dev/hdb5
# tune2fs -j /dev/hdb6
# tune2fs -j /dev/hdb7
# tune2fs -j /dev/hdb8

create mount points for the drive
# 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
# 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 insert the cdrom with the contents of the backup

It should mount automatically. You will be able to see it if you look in /mnt/cdrom. If it did not mount automatically, issue the following command.
# mount /mnt/cdrom
If you need to unmount the cdrom issue this command
# umount /mnt/cdrom

Navigate to the appropriate mount point for the newly prepared drive and decompress an archive to the corresponding mount point.
# cd /copy/1
# tar -zxvf /mnt/cdrom/partition1.tgz
# cd ../2
# tar -zxvf /mnt/cdrom/partition2.tgz
# cd ../5
# tar -zxvf /mnt/cdrom/partition5.tgz
# cd ../6
# tar -zxvf /mnt/cdrom/partition6.tgz
# cd ../7
# tar -zxvf /mnt/cdrom/partition7.tgz
# cd ../8
# tar -zxvf /mnt/cdrom/partition8.tgz
Now you have all of your files in place. You need to set up /etc/fstab so it matches the newly created partitions.
Note: /etc/fstab contains information telling the linux os what partitions to mount and where to mount them.

Open the file that has the screen captures of the commands you copied when creating the backup. Use your favorite text editor to tweak /etc/fstab so it works correctly. I will use vi.
# vi /copy/7/etc/fstab
Edit the fstab file and replace "LABEL=" with the corresponding partition assignment. I used the screen capture of the "df -h" command for reference of what partition matched with what directory.
see edited example

Now take out the power down the machine and remove the newly restored hard drive. You need to set the jumpers on the drive so it will be set as a master. Put the drive in the box that is to be your new server and try booting from it with your boot floppy. If you have lost your boot floppy, you can create a new one from the image that you saved on cdrom.

Restoring a floppy from a floppy image file goes here