tuxillo's corner

See if you can find anything useful here.

Easy Incremental Backups With HAMMER Filesystem

| Comments

Finally I’ve made some progress in one of my miniprojects! At least an initial version of the hammer-backup script has been pushed to the master branch upstream in the DragonFly BSD repository, see commitdiff here.

For those who don’t know, DragonFly BSD is a fork of FreeBSD 4.x. Its leader, Matthew Dillon, implemented a log structured filesystem from scratch called HAMMER. It’s divided into independent “sub filesystems” called PFS (pseudo-filesystem).

DragonFly BSD standard installation on a HAMMER filesystem provides a PFS for every typical UNIX system directory (/usr, /var), see below:

1
2
3
4
5
6
7
8
9
10
11
12
13
koprulu# df -h
Filesystem                                               Size   Used  Avail Capacity  Mounted on
ROOT                                                     926G    14G   912G     2%    /
devfs                                                    1.0K   1.0K     0B   100%    /dev
/dev/part-by-uuid/cb4561e2-8aaf-11e3-9867-535400123456   1.2G   303M   784M    28%    /boot
/pfs/@@-1:00001                                          926G    14G   912G     2%    /var
/pfs/@@-1:00002                                          926G    14G   912G     2%    /tmp
/pfs/@@-1:00003                                          926G    14G   912G     2%    /usr
/pfs/@@-1:00004                                          926G    14G   912G     2%    /home
/pfs/@@-1:00005                                          926G    14G   912G     2%    /usr/obj
/pfs/@@-1:00006                                          926G    14G   912G     2%    /var/crash
/pfs/@@-1:00007                                          926G    14G   912G     2%    /var/tmp
procfs                                                   4.0K   4.0K     0B   100%    /proc

HAMMER is a copy-on-write filesystem that records history of every change on it. It’s also transactional and every transaction has a transaction ID associated (TID). Here’s where things get really interesting, HAMMER provides a tool to operate the filesystem itself called ‘hammer’.

It can dump the contents of every PFS to stdout and that’s what the hammer-script uses.

You can see how the script itself works here

Comments