In order to backup my Linux and Mac OS X boxes I set up a FreeBSD server running Netatalk and rsync as daemon. Netatalk plays nicely with Time Machine on the Macs, while rsyncd handles all files sent from my Linux box. This is a home setup, so I want things to be easy and didn't install BackupPC, Bacula, or such. And since my backup server runs inside a virtual machine, I chose good old UFS2 over ZFS after some testing. Interestingly, ZFS (gzip) compression saved more free space (overall ratio was about 1.6:1 of real data to compressed data) than deduplication (benefit was just 1.05:1).
=> 34 41942973 ada0 GPT (20G) 34 128 1 freebsd-boot (64k) 162 33554432 2 freebsd-ufs (16G) 33554594 8386560 3 freebsd-swap (4G) 41941154 1853 - free - (926k)
WITHOUT_X11=yes WANT_BDB_VER=5
# make -C /usr/ports/net/rsync install cleanChoose Docs, SSH, and ZLIB_BASE only
# make -C /usr/ports/net/netatalk3 install cleanChoose DBUS, PAM, and SENDFILE
auth required pam_unix.so try_first_pass account required pam_unix.so try_first_pass session required pam_permit.so
# pw groupadd tm -g 548 # pw useradd tm -u 548 -g tm -s /usr/sbin/nologin -c "Time Machine user" -d /nonexistent # passwd tm
# gpart create -s GPT ada1 # gpart add -t freebsd-ufs ada1 # newfs -U -j ada1p1 # mkdir /backup # mount -o noatime /dev/ada1p1 /backup # mkdir -m 0700 /backup/macbook # chown tm:tm /backup/macbookrsync area:
# gpart create -s GPT ada2 # gpart add -t freebsd-ufs ada2 # newfs -U ada2p1 # mkdir /backup2 # mount -o noatime /dev/ada2p1 /backup2 # mkdir -m 0700 /backup2/linux # chown nobody:nobody /backup2/linux
/dev/ada0p2 / ufs rw,noatime 1 1 /dev/ada0p3 none swap sw 0 0 /dev/ada1p1 /backup ufs rw,noatime 2 2 /dev/ada2p1 /backup2 ufs rw,noatime 2 2
[Global] mimic model = TimeCapsule [macbook] path = /backup/macbook hosts allow = macbook valid users = tm time machine = yes vol size limit = 300000You can omit vol size limit if you use ZFS, create a separate file system for path, and set a quota of for example 300 GB for that file system.
pid file = /var/run/rsyncd.pid [linux] fake super = yes hosts allow = linux path = /backup2/linux read only = no
rsyncd_enable="YES" dbus_enable="YES" avahi_daemon_enable="YES" netatalk_enable="YES"
# service rsyncd start # service dbus start # service avahi-daemon start # service netatalk start
That's all! Neither a fancy avahi nor netatalk configuration is needed. On
your Mac open the Time Machine preferences, and click on Add or Remove
Backup Disk. Under Available Disks you can select the volume
exported by your backup server. If you do so, you will be asked for the
tm user's password.
On my Linux box I use a simple shell script to backup my workstation:
#!/bin/sh rsync -avAHS --del --progress --exclude=/dev --exclude=/media --exclude=/mnt \ --exclude=/proc --exclude=/run --exclude=/sys --exclude=/tmp \ --exclude=/usr/portage --exclude=/var/lib/nfs/rpc_pipefs \ --exclude=/var/tmp --exclude=/var/run \ / rsync://backup/linux/While Time Machine creates historical backups, I created a simple cron job on the backup server to snapshot the rsync area:
#!/bin/sh today=`date +%a` rm -f "/backup2/.snap/$today" mksnap_ffs "/backup2/.snap/$today"
Starting with Mac OS X 10.12, Time Machine over SMB is supported. Hence, I replaced Netatalk with Samba, and also moved the backup volumes to a ZFS filesystem on a FreeBSD 12 box.
# zfs create -o mountpoint=/timemachine zroot/timemachine
# make -C /usr/ports/net/samba48 install cleanI just selected these options:
[global] workgroup = WORKGROUP security = user netbios name = backup server string = backup.your-local-domain.invalid hostname lookups = yes load printers = no show add printer wizard = no time server = yes map to guest = Bad User use mmap = yes dos charset = 850 unix charset = UTF-8 mangled names = no log level = 0 vfs objects = fruit streams_xattr zfsacl fruit:model = MacPro fruit:resource = file fruit:metadata = netatalk ; time machines [macbook] path = /timemachine/macbook read only = no use sendfile = yes browseable = no hosts allow = macbook.your-local-domain.invalid fe80::/10 fruit:time machine = yes fruit:time machine max size = 500G valid users = tm
# zfs set refquota=500G zroot/timemachine
# smbpasswd -a tm New SMB password: <enter a secure password> Retype new SMB password: <repeat that secure password> # smbpasswd -e tmPlease note that Samba password for the user tm and its system password are not synchronized, and thus can be different.
# service netatalk stop # service netatalk disable # service samba_server enable # service samba_server start