1Backups

1.1 Create backup structure

As described in the backup script (/root/backup-slash-fs), the backup scheme is composed of seven steps:

  1. Create a FS snapshot using LVM

  2. Mount the snapshot FS

  3. Mount our backup file in a loop filesystem (we can guarantee the space will be present this way, and it allows selective recovery of files if need be)

  4. rsync the differences between the snapshot FS and the backup FS

  5. Unmount the backup FS

  6. Unmount the snapshot FS

  7. Delete the snapshot LVM (leaving it will degrade performance)

For this script to function, though, the initial backup structure must be made. The large portion that needs to be done manually is creating the backup file, but in order to do so, most of the steps outlined above will be performed.

First, create our backup file by touching /mnt/smb/userdata/root/FC6-Backup-File, and also create a the backup mount points at /mnt/FC6-Snapshot and /mnt/FC6-Backup. Next, start the backup process:

# Create the file system snapshot
lvcreate -s -L40G -n FC6Backup /dev/System/fc6

This is where the manual steps come in. Instead of mounting the file systems and using rsync between them, we want to copy the initial system, and conveniently we'll develop a file system large enough within the backup file simultaneously using dd.

dd if=/dev/System/FC6Backup of=/mnt/smb/userdata/root/FC6-Backup-File bs=64k

Wait for the copy to complete (it'll be a while). When that is done, confirm the file backed up the root file system, and then delete the snapshot file system.

mount -o loop /mnt/smb/userdata/root/FC6-Backup-File /mnt/FC6-Backup
ls /mnt/FC6-Backup
... # ls output
umount /mnt/FC6-Backup
lvremove -f /dev/System/FC6Backup

1.2 Automatic Backups

Enabling automatic backups is as easy as adding an entry in a cron tab or placing a link in one of the special cron directories. We want to backup nightly, so we'll add a link to /root/backup-slash-fs:

ls -s /root/backup-slash-fs /etc/cron.daily/backup-slash-fs