Using ZFS for TimeMachine

Using ZFS for TimeMachine

I have multiple Macs in my home and Time Machine daily backups can be a life saver if you're trying to find a file you accidentally deleted or if you want to migrate to a new Mac device.

I prefer to backup over a physical plugged in disk, since physical connections are always faster and more reliable, but it becomes annoying when it is about laptops. I am using a Samba server over WiFi to achieve that goal, however the problem was the backups on my pure disk based NAS were just too slow.

I have a WD EX2 Ultra with 2 TB disks, but instead of using that, I migrated to 2 HDD disks, attached via USB to my Big NAS boy, a mini PC. I also thought that adding a SLOG will make this go much faster, which it did. Here is the final configuration.

I created a pool and basically did the following configuration for speed optimized configuration. Since I know that my disks are CMR, write amplification is not an issue I was worried about.

zfs set compression=lz4       backup           # fast, space-saving
zfs set atime=off             backup
zfs set xattr=sa              backup           # macOS puts lots of xattrs
zfs set relatime=on           backup
# Use 16 K records if you prioritise write-amplification, or 1 M for pure throughput
zfs set recordsize=256K backup 

I then created volumes for each laptop like this:

MAC=macpro
zfs create -o refquota=1T -o refreservation=16G -o compression=lz4 -o recordsize=256K backup/tm_${MAC}

And then finally updated the Samba Configuration like this:

[TimeMachine-MacPro]
   path = /backup/tm_macpro
   read only = no
   vfs objects = catia fruit streams_xattr zfsacl
   fruit:time machine = yes
   fruit:time machine max size = 1T
   strict sync = no
   sync always = no