Title: Bare Metal Backup
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Bare Metal Backup

We will look at commands which can be run after booting a live CD such as SystemRescueCD or Knoppix.  The main advantage to this method is that no special software is required.  The main disadvantage is that it will require down time for the server to be backed up.

- In preparation, ensure that there is enough disk space on another server to hold a copy of the system which will be backed up.
- Check that ssh connections work between the two servers.
- Create and test a live CD, and ensure that you have access to the root account.
- Schedule a time for maintenance when the server can safely be unavailable.

At the chosen time, insert the CD and reboot the server.  You may need to change the boot order temporarily.  In the example below, the server to be backed up is prod-server and the fileserver is named backup-server.  The user account on backup-server is archive:

- The first step is to ensure that ssh connections work in the live environment.

ssh archive@backup-server

It will be necessary to accept the keys the first time you connect.  Logout after confirming the connection.

- The second step is to find all the partitions which need to be archived.  In this sample output, only two partitions exist on the hard drive.

# fdisk -l

Disk /dev/vda: 32.2 GB, 32212254720 bytes
16 heads, 63 sectors/track, 62415 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e90f4

Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3         523      262144   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             523       62416    31194112   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_root-lv_root: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_root-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_root-lv_var: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_root-lv_tmp: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_root-lv_home: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

#

- The third step is to copy the Master Boot Record (MBR) and each of the partitions to the correct path on the backup server.  Note that gzip is used to compress the data before it is transferred over the network.

dd if=/dev/vda bs=512 count=1 | \
ssh archive@backup-server "cat > /backup/prod-server/vda-mbr.img"

dd if=/dev/vda1 | gzip | \
ssh archive@backup-server "cat > /backup/prod-server/vda1.img.gz"

dd if=/dev/vda2 | gzip | \
ssh archive@backup-server "cat > /backup/prod-server/vda2.img.gz"

After the data has transferred, reboot the server and remove the live CD.  Be sure to keep the CD available where it can be found quickly in case of an emergency.