How to quickly set up Time Machine server on Ubuntu Server 12.04/14.04/16.04 and Debian without using extra repositories, unnecessary packages and redundant configuration. Backing up tested on OS X 10.6 Snow Leopard, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, OS X 10.10 Yosemite, OS X 10.11 El Capitan. If you have a problem, you might be able to find a solution in the comments section below the article.
Update: if you try this in CentOS, replace
yum where necessary.
If you need to install a new drive, follow the guide on Ubuntu Help.
1. That’s all you need to install:
sudo apt-get install netatalk avahi-daemon
2. Create a new user for Time Machine, for example, danny:
sudo adduser danny
3. Create a folder which will contain the backup. It doesn’t have to be located under /home or called “tm”.
mkdir -R /home/danny/tm/ sudo chown -R danny /home/danny/tm/
4. Backup the configuration file:
sudo mv /etc/netatalk/AppleVolumes.default /etc/netatalk/AppleVolumes.default.old
5. Create a new configuration file and open it for editing:
sudo nano /etc/netatalk/AppleVolumes.default
Paste the following line which sets default settings for all shares:
Then add this line to share a folder with danny:
/home/danny/tm "Danny's Time Machine" options:tm volsizelimit:300000 allow:danny
Do not touch “options:tm”! Obviously “volsizelimit:300000” limits the share to 300000 MiB (~314GB). (Finder will show “314GB available” when connected). Remove it if you want.
Important! Make sure you’ve replaced
/home/danny/tm with the actual path you chose in step 3. Otherwise you’ll be getting OSStatus 2 errors later on.
6. Restart netatalk:
sudo service netatalk restart
7. Connect to your server using Finder on your Mac: in “Go” menu, press “Connect to server…” (or ⌘+K). In server address field type afp://IP.of.your.server/ then press “Connect”. If all is well you’ll be asked for login and password (the ones you set in step 2). Once connected, open System Preferences > Time Machine, click “Select Disk…” and select your server under “Available Disks”:
Once again you’ll be asked for the login and password, after that you can disconnect from the share in Finder if you want, because Time Machine will open a new connection.
If you use Mavericks/Yosemite and you get “Check the server name or IP address, and then try again” error, run the following on your server:
cd /usr/lib/netatalk sudo mv uams_dhx2.so uams_dhx2.so.broken sudo ln -s uams_dhx2_passwd.so uams_dhx2.so sudo service netatalk restart
(Thanks Gary Corcoran!)
* * *
Bonus! Make your server appear as Xserve in Finder:
/etc/avahi/services/afpd.service for editing:
sudo nano /etc/avahi/services/afpd.service
2. Paste this:
<?xml version="1.0" standalone="no"?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=Xserve</txt-record> </service> </service-group>
3. Restart avahi-daemon:
sudo service avahi-daemon restart
* * *
(1) If you can’t connect to your server at all, try turning off the firewall if any, and see if connection goes through. If so, turn the firewall back on and try opening port number 548.
If your firewall is ufw, the following will turn it off:
sudo ufw disable
…and these commands turn it on and open port 548:
sudo ufw enable sudo ufw allow 548
(2) If you get OSStatus 2 errors, make sure the Time Machine directory (e.g. “/home/danny/tm”) is writable by your Time Machine user (e.g. danny). You can check that by running the following command which tries to create a file called test:
su danny touch /home/danny/tm/test
If you get an error, repeat step 3.
(3) If avahi-daemon does not start after rebooting the server (so the server doesn’t re-appear in Finder’s sidebar), change
AVAHI_DAEMON_DETECT_LOCAL from 1 to 0 in
/etc/default/avahi-daemon (more information in my post on ServerFault). Note that if it never appeared in the first place, probably it has a different problem.
(?) If you’re facing a different problem, try catching possible error messages.
On your OS X computer, open Console.app, click “Show log list” to open the sidebar and select “All Messages” there.
On your Linux server:
tail -f /var/log/syslog
(Ctrl + C to stop).
Then try to connect and see if any suspicious or error messages appear. If so, mention them while asking for help via comments or forums.