Forum

Full Version: NFS boot and backup script with LVM snapshot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
After testing and destroying my configuration a couple of time I get tired to backup and restore the SD using dd
So I moved Xbian in an NFS share on my media server following these instruction:
http://forum.xbian.org/thread-1531-post-17118.html#pid17118

I created a dedicated ext4 2G volume optimized for speed, following this:
http://erikugel.wordpress.com/2011/04/14/the-quest-for-the-fastest-linux-filesystem/

The volume is mounted as:
Code:
/dev/VG1/Xbian                                         /srv/Xbian           ext4       noatime,nodiratime,data=writeback,stripe=16,barrier=0,errors=remount-ro,nobh      1   1

and exported as:
Code:
/srv/Xbian               192.168.1.208(rw,sync,nohide,no_root_squash,no_subtree_check)

The I made a script to make a daily full backup, using LVM snapshot to keep a consistent copy.
I keep only the last 7 backup

Code:
#!/bin/bash
# simple 7 day backup

/sbin/lvcreate --size 1G --snapshot --name XbianSnap /dev/VG1/Xbian
/usr/bin/mount /dev/VG1/XbianSnap /mnt -o ro

data=`/usr/bin/date +"%d-%m-%Y"`
/bin/tar zcf /srv/backup_Xbian/Xbian_$data.tgz /mnt
/usr/bin/find /srv/backup_Xbian -type f -name Xbian* -mtime +7 -exec rm -f {} \;

/usr/bin/umount /mnt
/sbin/lvremove -f /dev/VG1/Xbian

If you don't have an LVM setup you can use the script removing the lvm and mount parts.

Now I'm planning to add a scheduled script in Xbian to backup the boot partition on the nfs volume:
Code:
mount /boot -o remount,ro
dd if=/dev/mmcblk0p1 of=/root/boot.img
mount /boot -o remount,rw
Reference URL's