Re: RAID gotchas!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ferguson, Michael wrote:

Justin W wrote:
I just backed up my server using a combination of an LVM snapshot, dd to
copy the partition initially, and now it'll be maintained with nightly
rsyncs to a mounted image file. (Note: If anyone is interested, I can post
some documentation describing how I set up the backup and the script which
will keep my backup up-to-date).

Justin, Thanks for the offer. Please post, or send me the documentation on
how to.

'preciate it.
Ferg'

I'm currently in the process of rewriting the script and such so that there is not so much manual input. If I succeed, the script should be quite portable across similar setups, but for now, you're going to have to change many of the path names to how they apply to you.

The documentation is in the file backup.html which I've attached, and then the script which accompanies it is in the file backup-slash-fs.

If I get the new version completed in a reasonable amount of time, I'll repost that one too, but I'm not making any promises.

Justin W


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

#!/bin/bash

# Overview of backup process
#  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)

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

# Mount our filesystems
mount /dev/System/FC6Backup /mnt/FC6-Snapshot
mount -o loop /mnt/smb/userdata/root/FC6-Backup-File /mnt/FC6-Backup

# Update the backup file system with files from the snapshot
rsync -aHEAXxv --stats --delete --ignore-errors /mnt/FC6-Snapshot/* /mnt/FC6-Backup

# Unmount the backups
umount /mnt/FC6-Backup
umount /mnt/FC6-Snapshot

# Delete the snapshot
lvremove -f /dev/System/FC6Backup

# Create a link to the backup file which (in the name) indicates the date of
# the backup
cd /mnt/smb/userdata/root
rm -f FC6-Backup_*
ln -s FC6-Backup-File FC6-Backup_$(date +%F)


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux