Time Machine for MacBook's

Apple MacBook backups to a Docker based VM, `timemachine`. Adding the Samba share and then add the storage to your Time Machine as usual.

Time Machine for MacBook's

My laptop is a MacBook Pro, and we have 2 more MacBook in the house. Backups are essential. I run one to my main NAS, one to a remote disk and now adding a Docker based to it, it runs Samba as for the storage.

I use a Docker and Samba combo from Thomas Willems, willtho89 on GitHub. This is an old project without updates for 5 years, but it still works in our house.

Installation

I use Dockge as my tool to deploy and manage Docker Compose files. Use a small VM 1 core, RAM 1 GiB, 8Gib Disk, and add a data disk of a proper size e.g., 256 GiB on a ZFS-2 device. The same VM also does my Syncthing storage on a different 32 GiB Disk. You should install avahi on this VM.

Add the storage for the synchronized files

Add a virtual disk (sdb) and create a partition on it. Make a filesystem mkfs.ext4 /dev/sdb1 and mount it with sudo mount -t auto -v /dev/sdb1 /sync/.

Find the UUID ls -l /dev/disk/by-uuid and edit /etc/fstab, add the line /dev/disk/by-uuid/<UUID> /sync ext4 defaults 0 2. The fs_passno of 2 means check filesystem after the root filesystem is checked, for no check use 0.

The root filesystem should be specified with a fs_passno of 1. Other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. Defaults to zero (don’t check the filesystem) if not present.

The Dockge files

version: "3.3"
services:
  samba-timemachine:
    network_mode: host
    volumes:
      - /timemachine:/timemachine/
    environment:
      - TM_USER
      - TM_PW
      - TM_ID
      - TM_SIZE
    container_name: timemachine
    image: willtho/samba-timemachine
    restart: unless-stopped
networks: {}

My compose in Dockge

TM_USER=myname
TM_PW=myloginpassword
TM_ID=1000
TM_SIZE=1024000

The .env file in Dockge. TM_SIZE is quota for Time Machine Size in MB

Set up MacBook

Connect to the server running the VM smb://<IP> and login.

Go to Time Machine settings and add a new destination.

Increase virtual disk size

When the disk size runs out, you need to expand the vdisk and run two commands in the VM. It usually ends up to be too small.

  1. Go to Disk Action and tell how much more space you like to have in GiB
  2. sudo growpart /dev/sdd 1 --update auto
  3. sudo resize2fs /dev/sdd1
  4. Check for success df -h

References

The Docker Samba Timemachine [1] Install Docker and Dockge on a VM [2]


  1. willtho89 Docker Samba Timemachine GitHub ↩︎

  2. Docker and Dockge install blog post ↩︎