TimeMachine is the way to backup your data on Mac systems. The backup and restore procedure work nicely out of the box with very little hassle involved. I used to backup my data on a local USB disk for some years. However, backups to a USB disk require you to connect the disk, otherwise no backups will be performed.
Apple will sell you the Airport Time Capsulate, which allows for remote backups. But it is also possible to configure your Raspberry Pi to offer remote backup capabilities for the TimeMachine. Turning your Raspberry into a backup target for the TimeMachine is as simple as installing an AFP server on it. In this blog post, I’ll walk through the process of configuring your raspberry to be a remote target for TimeMachine backups.
You need the following things to get started:
- Raspberry Pi
- SD card
- storage device for the backups, e.g. a USB hard disk
- Raspbian OS image for the Pi
- network connection to your local network
Install Raspbian on the device and connect it to your network. There are many installation guides for installing the Raspbian image out there. Since I assume that you are using a Mac, you might want to have a look at this guide for information on how to install Raspbian to the SD card of your Raspberry Pi.
After connecting the device to your home network, you should be able to connect to your device via its assigned IP address. You should assign a static IP address to the device, or make sure that the device has a internal DNS name in your home network. If you have a FRITZ!Box in your home network, then this article can tell you how to setup this for your Raspberry.
The TimeCapsulate functionality requires that the Raspberry provides network shares over the AFP protocol.
The protocol is a proprietary file protocol that has been around on Mac systems for quite some time. There is a free open source implementation of the protocol which is provided by Netatalk. This server allows you to create a file server that can be used as a target for your TimeMachine backups.
As always with Raspbian, installing software is easy. Run
sudo apt-get install netatalk
to install the package. Then make it available at boot time by running
sudo update-rc.d netatalk defaults
There are a number of configurations that you need to adopt. First, choose a directory on your USB drive that you want to use as a TimeMachine target. In this example, we assume that you want to store your backups at
The first file you need to edit is
You can first delete the sharing of the Raspberry’s users home directories (if you want to). Identify and delete the line
~/ "Home Directory"
in the config file. Remove it and replace it with your upcoming backup location. For this, you need to decide
- who should be allowed to access the share, i.e. which user
- a fancy name for the share
- the size of the share, i.e. how much backup space you want to allocate to the TimeMachine. This can be handy if you want to use the disk for other data as well.
Using this information, you can create your config line:
/mnt/timemachine "\<fancy_name_for_share\>" allow:<user> cnidscheme:dbd options:upriv,usedots,tm volsizelimit:<size_in_megabytes>
For example, you can configure the AFP share as
/mnt/timemachine "My_MacBook" allow:pi cnidscheme:dbd options:upriv,usedots,tm volsizelimit:100000
for a volume called My_MacBook that is accessible by the user pi and can take up to 100GB of disk space.
Note that the user that you define in the allow section must be a valid user on your Raspberry Pi and needs write permissions on the directory /mnt/timemachine.
Now restart the Netatalk service to make the new configuration available:
service netatalk restart
Start the TimeMachine and choose to configure your backup.
Click the button Select Backup Disk …. You should see your AFP with the previously defined share name:
Select your share and tick the check box Encrypt Backups (recommended). Enter your credentials after selecting the disk. Your MacBook should now start to perform the backup to the Raspberry.