Forum
NFS boot and backup script with LVM snapshot - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Others (/forum-24.html)
+--- Thread: NFS boot and backup script with LVM snapshot (/thread-2113.html)



NFS boot and backup script with LVM snapshot - Fabio72 - 13th Feb, 2014 02:14 AM

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