7

I want to backup my Mac to a network drive mounted on my Ubuntu computer. How do I set this up?

amc
  • 7,142

1 Answers1

10

NOTE: this is now out of date. See linked question re: TimeMachine in High Sierra

This is actually really straightforward. My solution below works for a single user, but can likely be easily adapted for multiple users.

On the Ubuntu machine:

  1. Make sure the directory to be shared is mounted and owned by your user (e.g., your backup hard drive is mounted at /mnt/backups in /etc/fstab, and you've created a subdirectory called myMac in this backup folder). Because this is a network share it actually doesn't matter what format the disk uses - it could be ext4, btrfs, etc.

  2. Install netatalk (open source AFP):

    sudo apt-get install netatalk
    
  3. Configure the Apple share by editing location at the bottom of the /etc/netatalk/AppleVolumes.default file (comment out the line with the home directory and add the actual mount location; add your username):

    #~/                "Home Directory"
    /mnt/backups/myMac "TimeMachine"    allow:username options:tm,usedots,upriv
    

    (I'm not sure that options:usedots,upriv needs to be explicitly set but it works for me.)

  4. Restart the netatalk service:

    sudo service netatalk restart
    
  5. Make sure ports 548/tcp and 5353/udp are open in your firewall.

On the Mac machine:

  1. Open the terminal and enter:

    defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
    
  2. Reboot the computer.

  3. Mount the network share location by selecting the network share from the leftmost pane in a Finder window, or by selecting "Connect to server" from the Finder app's "Go" menu (or press +K) and enter the machine name or IP address of your Ubuntu machine:

    afp://123.456.789.123
    

    Use your Ubuntu user credentials to authenticate when prompted.

  4. Go to Time Machine preferences (accessible from "System preferences") and select "Change location", selecting to encrypt backups, and begin the backup setup process.

    • This will automatically create the sparsebundle file necessary for backups.
  5. After setup is complete, wait ~90 seconds for backup to automatically begin, and even longer for it to complete ☺

amc
  • 7,142
  • brilliant tutorial! – maxisme Mar 13 '16 at 23:27
  • Stacks of thanks for your concise and well written tutorial! – fusion27 Nov 18 '17 at 15:44
  • 2
    because it took me way too long to realize it, the "username" in step 3 is the actual user name, e.g. "daniel". – user2482876 Jan 13 '18 at 16:18
  • My Ubuntu has "PasswordAuthentication no" in the sshd_config. But I have my Mac's public RSA key in the Ubuntu's authorized_keys. I'm getting "Error 22, errno 2". Is that because using authorized keys can't work on this? Or is this supposed to be able to work without passwords and I'm doing something else wrong. – Joe C May 22 '20 at 19:57