Share this post!

← ../

Enable Time Machine backups to NFS share

May 14, 20223 min read

Have you ever wanted to use Time Machine to backup your Mac, but you don't have any compatible target devices? I found myself in a similar situation, thus I did some research and figured out a fairly simple and easy way to achieve my goal.

In order for this to work, you'll need any device that's capable or running a Samba (NFS) server (e.g. a Raspberry Pi) and some storage.

Server preparation

Load any Linux distribution onto the Pi and install the following packages:

apt install samba cifs-utils

After you've install the packages, you'll need to configure the Samba server. Doing so is very simple because the configuration is mostly done already. All we need to do is to set up a share and point it to a given directory.

Open /etc/samba/smb.conf and add the following lines at the end of the file:

[SSD-NAS]
   comment = Home SSD NAS
   path = /mnt/backups
   read only = no
   guest ok = no

Then create the directory /mnt/backups using this command:

mkdir /mnt/backups

After you've done that, you'll need to mount the mount point before it can be used. Note: If you're backing up to local storage, feel free to ommit this step.

Find the disk you'd like to use and format it to your liking. In my example, I'll use a USB stick labeled /dev/sdb and format it to btrfs.

Formatting the USB stick
Formatting the USB stick to btrfs

If you can't find the mkfs.btrfs command, you can find it in the btrfs-tools package. You can install it by running the following command: apt install btrfs-progs.

Next step is to get the partition's unique identifier and have it automatically mount on boot. Use the command shown in the screenshot below to get the UUID of the partition.

Getting the UUID
Getting the UUID of the USB stick

After you get the UUID, you can the following line to the /etc/fstab file:

UUID=07e567c7-31dd-4c5c-a6ac-d37ce78268ae /mnt/backups btrfs defaults 0 0

If you've done everything correctly, you should be able to mount this partition as shown in the screenshot below. In my case, I mounted /dev/sdb1 to /mnt/test.

Mounting the partition
Mounting the partition

In the next step, you'll need to add a new user and set a password for it. I've used someuser just for this example.

Adding a new user
Adding a new user

Once you've completed this step, your SMB server is almost ready to use. The final command you need to execute is the following:

systemctl restart smbd

Client setup

MacOS likes to be a little picky regarding what can be used as a backup target so we'll need to change a few settings that aren't accessible from the GUI. Open a terminal window and run the following commands:

sudo defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

This command will make Time Machine show all volumes that are not supported by the OS. Since NFS isn't natively supported, you'll first have to create a disk image for the backups.

Open Disk Utility and create a new disk image by pressing ⌘ + N then create a new disk image with the following settings and save it to any location you'd like:

Creating a new disk image
Creating a new disk image

Please note that the size you specify is the maximum size of your backups. Once you've created the disk image, we'll need to mount the NFS share and move the disk image to it.

To do that open Finder and press ⌘ + K then enter the IP address of your NFS server as shown in the screenshot below.

Mounting the share
Mounting the share

If you've done everything correctly, you should be able to mount the NFS share as shown in the screenshot below.

Signing in to the Samba server
Signing in to the Samba server

Select the share you've defined in the previous steps and then copy the disk image to the share. Once the file is done copying, you'll need to mount it by double clicking it.

Mounting the disk image
Mounting the disk image

The final couple of steps are to make the image automatically mount and to set it as the default backup target. You can do so by opening System Preferences and then clicking on the Users and groups tab then switching to Login items. Once you're at the right tab, you'll need to add first the NFS share and then the disk image to the list.

You can do so by dragging the directories (folders) to the list.

Adding items to startup
Adding items to Login items

The final thing we have to do is to set the disk image as the default backup target. Double click the disk image on the NFS share and wait a couple seconds for it to mount. Then open the terminal and type mount and find the disk image you just mounted - in my case it's path is /Volumes/Backup of Nik's MacBook Air.

After you've determined the path, you can set it as the default backup target by typing the following command:

sudo tmutil setdestination "/Volumes/Backup of Nik's MacBook Air"

If you've done everything correctly, you should now be able to use Time Machine.

Time Machine
Time Machine backing up to a NFS share

Published May 14, 2022, by Administrator.

If you enjoyed the post, consider sharing it!

Copyright © 2022