Image Image Image Image Image
Scroll to Top

To Top

code

30

Jun
2013

No Comments

In code

By admin

ubuntu and btrfs backups using send receive

On 30, Jun 2013 | No Comments | In code | By admin

Since I’ve moved to Ubuntu Linux I’ve been mostly using btrfs for all my filesystems. btrfs makes it super easy to create snapshots of subvolumes and to go back in time to a previous snapshot (just use mv). I always create a snapshot before updating packages so that I can easily go back if something breaks.

I’ve been using Back In Time for my backups but this app takes more then 30 minutes for  every single backup, no matter how small, and does a lot of disk I/O in the process, even just to transfer 2 or 3 files (I think that happens because it’s creating  hard links).  I’ve recently discovered that btrfs has a send / receive functionality which allows sending a snapshot to another btrfs partition and it also allows to send just the diff between snapshots. Using btrfs send and btrfs receive it’s possible to setup a backup process entirely based on btrfs.

I found that btrfs send / receive is broken  in the current ubuntu version 13.04, so I had to uninstall the btrfs-tools package and compile from the source in git of btrfs-progs. After that btrfs send and btrfs receive seem to work fine. I’m now doing all my backups with btrfs which on average now take just one or two minutes, much much faster then with Back In Time.

Finally I created a Haskell Shelly script to automate my backup procedure. It’s still very incomplete, but I put here in case it’s useful to others. Be careful with this script, it might delete snapshots that it shouldn’t so use at your own risk !

Tags |

Submit a Comment