Ryan
Ryan Author and sole creator of That Virtual Boy and its content including articles, tools, and apps.

Send Time Machine backups to a VM hosted in Windows


I've successfully configured Time Machine backups over my home network using VMware Workstation, Ubuntu, and a 1 TB WD drive. A big thanks to HowToGeek for their Raspberry Pi post for the inspiration and to Netatalk's Wiki. Here we go!

screen-shot-2016-11-03-at-8-44-29-am:: Prerequisites


  • Windows (using Windows 10 in this tutorial)

  • VMware Workstation (using 12.5 Pro)

  • Linux ISO (using Ubuntu 16.04 mini.iso)

  • Dedicated backup drive (using a 1TB WD) formatted as HFS+

  • macOS Seirra

:: Prepare your drive


Format your hard drive to be HFS+. This can be done by booting to any linux live disk and using gparted. You'll likely need to install hfsprogs and hfsplus to enable the formatting.

When attached to your Windows Host system, Windows won't mount this drive in Explorer, but you can still see it in Windows Disk Management to ensure it's working properly. Here it shows as Disk 0screen-shot-2016-11-02-at-9-22-21-pm

Choose a mount point that your backup server will use for the drive. I'll use /media/tm
Choose a user that will connect to your backup server from the Mac. <your-user>

Save these for later.

:: Setting up the dedicated backup server


I run my personal servers on a Windows 10 box under VMware Workstation. It's plain simple, easy to administer and maintain, and works great for home needs. Because I like dedicating my servers to individual VMs, I wanted a small VM to attach my 1 TB backup drive to - something with a small footprint as I won't need to interact with the OS much. This is why I chose to use Ubuntu's mini.iso

  1. In Workstation, create a new VM using the mini.iso. The only 'options' I chose to install with it were opensshserver for management, and samba (might use this in the future). My VM uses 512 MB of RAM and 1vCPU.

  2. Obtain HFS+ support by running
    sudo apt-get install hfsprogs hfsplus

  3. Let's take a moment to add our disk to the VM. I chose for my VM to have direct access to the physical disk as its primary purpose will be for backups.screen-shot-2016-11-02-at-9-25-48-pm
    screen-shot-2016-11-02-at-9-26-09-pm

  4. Now boot the VM back up, and mount the drive
    sudo mount -t hfsplus -o force,rw /dev/sd* /media/tm

    You should also add this to /etc/fstab so it mounts properly at boot
    /dev/sd* /media/tm hfsplus force,rw,user,auto 0 0

  5. Setup permissions for your user that will connect to the server
    sudo chown -R root:users /media/tm
    sudo chmod -R g+rwx /media/tm
    sudo usermod -a -G users <your-user>

  6. Once that's done, follow Netatalk's Wiki on setting up v3.1.10 (current at time of writing) on Ubuntu 14.04 (my server is using Ubuntu 16.04 and I can attest it works). Here are the commands for reference:
    sudo apt-get install build-essential libevent-dev libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libtdb-dev libmysqlclient-dev avahi-daemon libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libio-socket-inet6-perl tracker libtracker-sparql-1.0-dev libtracker-miner-1.0-dev

    wget http://prdownloads.sourceforge.net/netatalk/netatalk-3.1.10.tar.gz

    tar -xf netatalk-3.1.10.tar.gz

    cd netatalk-3.1.10

    ./configure --with-init-style=debian-systemd --without-libevent --without-tdb --with-cracklib --enable-krbV-uam --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d --with-tracker-pkgconfig-version=1.0

    make

    sudo make install

     
  7. Now edit your /etc/nsswitch.conf and append mdns4 mdns to the end of the hosts file so it looks like this
    hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

     
  8. Create the file /etc/avahi/services/afpd.service with the below contents
    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
    </service>
    <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=TimeCapsule</txt-record>
    </service>
    </service-group>
     

  9. Setup the Netatalk AFP File Server config file /usr/local/etc/afp.conf
    [<your-user>]
    path = /home/<your-user>
    rolist = <your-user>

    [Global]
    mimic model = TimeCapsule6,106

    [Time Machine]
    path = /media/tm (or whatever your mount point is)
    time machine = yes

  10. Run the init scripts in this order
    sudo /etc/init.d/avahi-daemon start

    sudo service netatalk start
  11. Add services to default runlevels
    sudo update-rc.d avahi-daemon defaults
    sudo update-rc.d netatalk defaults

  12. Back on your Mac, add your Ubuntu machine to /etc/hosts
    x.x.x.x <ubuntu-hostname>

  13. At this point, you should be able to connect to the server via hostname. From Finder Window, press command+K and enter the server address afp://<ubuntu-hostname> 

  14. Open Time Machine Preferences and select the Time Machine disk
If you don't see your disk in Time Machine preferences, ensure that it was mounted as read/write on the backup server. Good luck!

comments powered by Disqus