28 May 2018

If you have a MacBook or similar the easiest backup solution is Time Machine and having a small server that is always ready to backup is my recommended option, as using an external disk depends on you remembering to plug it in.

The best option was the AirPort Time Capsule but Apple discontinued it last month. Nowadays there are quite a few networked hard drives that advertise support for Time Machine but if you have a Raspberry Pi or a computer that is mostly on all the time you can just build your own. Plus, you get to launch other things on that server, including other systems for non-time machine compatible devices.

In this post I'll just talk about how to setup a Time Machine server using a docker container.

After trying various containers, I've settled on this one. It hasn't changed in a while but still works fine.

First, clone the repo, or the fork of it I have under my account and build it, by running this inside your server machine:

git clone https://github.com/arve0/docker-timemachine
docker build docker-time-machine/ -t local/docker-timemachine

You will need docker community edition for that, but I won't go into that here as it depends on what device you are actually using, it should be as easy as going to their site and finding a version.

On a side note, be aware that docker (the company) is in dire need of a business model and will try to trick you into trying their bloated products. You just need the community edition runtime engine.

Now, decide where you will be storing the backups. If it is an external drive make sure that it is plugged in before starting the container. Say you want to store in /media/time-machine.

Then, create a new docker container that will hold your server and the parameters it needs.

  1. Replace the password below with one that will be used to allow access to the server (the backups themselves can be encrypted with a different one). The user name will be TimeMachine.

  2. Replace /media/time-machine with the location for your backups

docker create --name timemachine --restart=always -e "PASSWORD=CHOOSE_ONE" -v /media/time-machine:/backup -p 548:548 --net=host local/docker-timemachine

The container above has --net=host which indicates a privileged container and may be dangerous if it gets hacked although in a normal/personal setup you won't be making it accessible to the Internet so the risk is minimal. Enabling it makes the Time Machine server discoverable (ie it shows in Finder). If you want, you can remove it and just use afp://nameofyourhost to connect, also if for some reason your server doesn't show in Finder, just go open Finder, then /Go/Connect To Server and type in that to make it show.

Finally, from you Apple device, launch Time Machine preferences, Click Select Disk and then select your server. Input user name TimeMachine and your password and don't forget to select [x] Encrypt backups on the Mac OS X Time Machine dialog to add another layer of protection.

UPDATE: Recovery

I finally had to use the time machine backup after a bug in Disk Utility destroyed my partition table (a whole story in itself), and one thing I noticed is that a full recovery from a Time Machine backup is very slow, and anecdotal evidence from twitter peers said this is a problem with Time Machine itself (that affects even Airport based devices etc). My backup was taking about 700GB, including all the history and it was encrypted, I believe TC has to walk through a lot of that data to find the latest versions so it took forever (about 13h), but the worse part is that it kept failing. My recommended solution: don't use time machine to do a full recovery. Simply install a clean system, then launch migration assistant a few times to recover everything, first settings, then your user, then apps. This worked flawlessly.


(Follow me on Twitter, on Facebook or add this RSS feed) (Sígueme en Twitter, on Facebook o añade mi feed RSS)
details

Comments