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
1Backups1.1 Create backup structureAs described in the backup script (
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
# Create the file system
snapshot 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 1.2 Automatic BackupsEnabling 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 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)