Macos – Time Machine on a local drive, then make that drive a network drive (via Server.app) on a different computer

afpbackupmacosnastime-machine

I have two macs running OS X 10.10.3. One has Server.app installed, is connected to the internet via ethernet, and also has a 2 TB disk attached via USB, with two partitions – "Backup" and "Storage". My other mac is a laptop used for schoolwork.

Using the Time Machine feature of Server.app, I was able to use the standard Time Machine interface to begin backing up my local mac onto the "Backup" volume on the server mac over the network.

However, I discovered that it takes 7 minutes to copy a 1 GB file over AFP, so backing up 300 GB on my local mac would take at least 35 hours.

So, I'm trying to figure out a way in which I could do the initial 300GB backup onto "Backup" over USB, and then connect that external hard drive to the server mac and continue doing backups over the network. That way, the incremental network backups would be much smaller than 300GB and could be done in a reasonable time period, e.g. overnight.

Any suggestions? I read the man page for tmutil but I'm not very comfortable with it just yet.

Best Answer

Better later than never, here is a hack to achieve this :

sudo ifconfig lo0 alias 127.0.0.2/32

Plug your usb drive, then via System Preferences / Sharing add a smb share to a folder time-machine-macbook in the drive time-machine-usb Then, add a destination backup (Time Machine will see it as a network share)

sudo tmutil setdestination -a "smb://user:password@127.0.0.2/time-machine-macbook"

You can see if it's ok with:

tmutil  destinationinfo
> ==================================================
Name          : time-machine4
Kind          : Network
URL           : smb://kenji@realserver._smb._tcp.local./time-machine
ID            : D820D053-C74A-4A06-A7E1-E60C8EA7934F
====================================================
Name          : time-machine-macbook
Kind          : Network
URL           : smb://user@127.0.0.2/time-machine-macbook
Mount Point   : /Volumes/time-machine-macbook
ID            : F707BD0B-64DF-4DB6-A3B7-824470FB5EB2

Then start a backup with tmutil startbackup and mount will show:

/dev/disk3s1 on /Volumes/time-machine-usb (apfs, local, nodev, nosuid, journaled, noowners)
//user@127.0.0.2/time-machine-macbook on /Volumes/time-machine-macbook (smbfs, nobrowse)

You can see detailed progress with tmutil status:

Backup session status:
{
    BackupPhase = Copying;
    ClientID = "com.apple.backupd";
    DateOfStateChange = "2018-06-28 17:38:21 +0000";
    DestinationID = "F707BD0B-57DC-4DB6-A3B7-824470FB5EB2";
    DestinationMountPoint = "/Volumes/Time Machine Backups";
    FirstBackup = 1;
    Percent = "0.08711567546702646";
    Progress =     {
        TimeRemaining = 32679;
        "_raw_totalBytes" = 355694600192;
        bytes = 34429528173;
        files = 887351;
        totalBytes = 391264060211;
        totalFiles = 2922384;
    };
    Running = 1;
    Stopping = 0;
    "_raw_Percent" = "0.09679519496336274";
}

In my case, near 1000000 files were done in about two hours (USB2 disk penalty, versus more than 8 hours via Wi-Fi), I calculate percentages with a small script:

tm-progress.sh
Files : 918702 / 2922384 (31.43%) - Bytes : 32.21 GiB / 364.39 GiB (8.84%)

We can here that many files can make Time Machine to progress "slowly" in Bytes, but nearly 1/3 of files have been copied.

Next step, when backup is finished, plug the usb drive to your realserver and copy the sparsebundle over the "uncompleted one" (or in the shared folder). Of course, Time Machine should be disabled during this step to prevent mounting a partially copied sparsebundle (and maybe corrupting it)

I have used an apfs drive to benefit of snapshots (to be able to revert to a previous "backupdb" in case of sparsebundle corruption, not tested yet)

Edit: even faster mode :


Once the backup has reached BackupPhase = Copying to make it faster you can make the backupbundle mount directly (without sending every operation through smb) by canceling the backup, renaming My-Computer.backupbundle to something like 1My-Computer.backupbundle, and creating a symbolic link :

ln -s /Volumes/time-machine-usb/1My-Computer.backupbundle /Volumes/time-machine-macbook/My-Computer.backupbundle

This tricks timemachine into following the link to the backupbundle localy, and not mount it through smb, which speeds up the backup. Make sure you move the backupbundle back when you have finished your local backup.


Related Question