Search A-Z index Help
University of Cambridge Home Physics Dept Home Mike Roses' Home Page TCM Group Home

Simple HowTo for Backup and Restore of Linux System Disk (/)

This seems to be a nice simple way to backup the system disk of a linux computer. You can put a second disk into a linux server (e.g. webserver) and backup to that.

make a bootable copy of a disk onto a second disk and
then copy / from /dev/sda1 to /dev/sdb1

# copy partitioning from sda to sdb
sfdisk -d /dev/sda | sfdisk /dev/sdb

# make file systems on new disk (sdb):
mkswap /dev/sdb2
mkfs -t ext4 /dev/sdb1

# mount backup disk (sdb) at /sdb1
mkdir /sdb1
mount /dev/sdb1 /sdb1

# dump from / (sda1) to sdb1 mounted at /sdb1
cd /sdb1
/sbin/dump -z -0 -f - / | restore -rf -

dump to another disk in the computer (or could be remote if you like):
cd /
/sbin/dump -0 -f /backup/hda2.dump / 2>>/var/log/manual_backup_os

in the above / is /dev/hda2 and swap and /dev/hda1. 
/backup is /dev/hdd2.

backup partition info to another disk:
sfdisk -d /dev/hda > /backup/partition_info
sfdisk -l /dev/hda >> /backup/partition_info

Can schedule a regular(ish) dump using cron (maybe once per month?)

You might also want a copy of sfdisk (not always on boot CDs)
cp /sbin/sfdisk /backup

OS used for these examples is Suse9.1 Pro.

disk dead and need to restore OS, so a new disk is fitted:

boot from cd/floppy (Knoppix/Tom's/Suse install CD) 

mkdir /backup
mount -t ext3 /dev/hdd2 /backup
cd /backup

Now to partition new disk:
cat partition_info | sfdisk /dev/hda
fdisk /dev/hda
and do it manually.

Make file systems on new disk:
mkswap /dev/hda1
mkfs -t ext3 /dev/hda2
mount /dev/hda2 /hda2
cd /hda2
restore rf /backup/hda2.dump

Note: you may need to edit:
if you are restoring to a different partition setup.

Should have a bootable system disk, now we need to configure grub to boot it:

boot from grub floppy/cdrom (boot restored / on /dev/hda2 which is hd(0,1) to grub)
(link at bottom of page to example grub iso boot CD image) or a Linux boot CD like knoppix

You might need to install grub:
grub-install /dev/hda
grub-install /dev/sda

if initrd and vmlinuz are in /boot, otherwise you will need:
grub-install --root-directory=/mnt /dev/sda

If you are not sure which partition actually holds this directory, use the command
find, like this:
grub> find /boot/grub/stage1

Define the root device (boot partition)
grub> root (hd0,1)

Once you've set the root device correctly, run the command setup (see setup):
grub> setup (hd0)

Now try booting your newly recovered system disk and it should work.



man dump
man restore
An iso image of a relatively generic grub boot CD (you might need to right-click and "save as")