Thursday, March 25, 2010

Quick local backup with rsync & btrfs

I needed to put a spare eSATA drive to use as a backup for my main Corporate box, but I also wanted to try out Btrfs & use its snapshot capabilities to aid in that effort. Using Ubuntu Karmic / 9.10 ...

1. Make sure a newer kernel is loaded from mainline: I'm using 2.6.33 @ the moment.
2. sudo apt-get install btrfs-tools
3. Attach the backup drive & partition as needed using fdisk.
4. mkfs.btrfs (new partition)
5. Create a directory to mount to, such as /media/backup
6. Edit /etc/modules to add btrfs
7. Edit /etc/fstab with the following modified for your needs...

(new partition) /media/backup btrfs compress 0 0

8. Update your boot files with update-initramfs -u
9. Make a backup script to run daily: example /etc/

DATE=`date +%F`
rsync -avlh (folder to backup) /media/backup/(folder to backup)
btrfsctl -s /media/backup/$DATE /media/backup

9. Add the script to your /etc/crontab file (and maybe run /etc/init.d/cron restart afterwards)

30 20 * * * root sh /etc/


* Btrfs Wiki
* "Back up like an expert with rsync"
* Blogger's entry on getting btrfs to work with Debian/Ubuntu