CS615A -- Aspects of System Administration - Backup Exercise

Using dump(8) and restore(8)

An incremental restore

Create an EC2 instance and perform a level 0 backup of the entire file system using the dump(8) command:

$ ssh ec2-instance "/sbin/dump -u -0 -f - /" | bzip2 -c -9 > ec2.0.bz2

Install a webserver using the native backage manager and configure it. Once you have everything working, create an incremental backup:

$ ssh ec2-instance "/sbin/dump -u -i -f - /" | bzip2 -c -9 > ec2.1.bz2

Inspect the different files and verify that the incremental backup contains only a (small) subset of the files contained in the complete backup.

Now simulate some data loss:

$ ssh ec2-instance
# pkg_info | wc -l
      14
# rm -f /usr/pkg /var/db/pkg
# echo "Oh no! What a mess!"
# exit
$ 

Use your incremental backup to restore the lost files:

$ bzip2 -d -c ec2.1.bz2 | ssh ec2-instance "cd /; /sbin/restore xf -"

Verify that all your software is back in place:

$ ssh ec2-instance /usr/sbin/pkg_info | wc -l

But restoring the full data from the backup is a bit of a waste if all you lost was a few files. Delete one or two select files, then Use restore(8)'s interactive mode to only restore exactly those files that you deleted.

A full restore

Next, let's restore the complete filesystem into a separate volume: create a new volume of the same size as the instance file system, create a single partition on it, create a new filesystem, and mount it on the existing instance under /mnt.

Restore the entire backup into the new location. Note that you will have to apply both backups in order to recreate the final end state. Verify that the filesystem on the new volume is identical by chroot(8)ing into /mnt and e.g., running your usual package utilities in there.

Restoring to a separate instance

We have a full backup of our instance, so can we now delete it and later restore it? Let's give it a try!

Terminate the instance and create a new one. Then extract your level 1 backup only over the root directory of the new instance. Did this bring your new instance into the same state as your previous instance was?

Now revisit the concept of "shareable" vs. "unshareable" data as explained in our discussion of Software Installation and Package Management; how does this apply in this context? Can we restore our level 0 backup over the new instance? Give it a try, then reboot the instance.

How could you structure your backup strategy to allow for restoration of the full filesystem across different EC2 instances?


[Course Website]