Use your NAS, or any network share, for backing up your Mac with Time Machine. Apple's backup software officially only works with supported devices, but with a little work you can trick it into backing up to any network drive!

In 2011, James showed you how to back up your Mac to a homemade time capsule. Any alternative to Apple's $300 wireless backup unit is welcome, but this method doesn't work any more.

Happily, there is a way around this for Macs running OS X Yosemite. To summarize, we're going to do four things:

  1. Create a sparse image – a virtual drive that Time Machine will see as a valid backup disk.
  2. Copy the sparsebundle to your network drive, then mount it.
  3. Tell Time Machine to use the mounted sparsebundle for backups.
  4. Tell your Mac to mount the virtual drive at boot.

Do these four things and your Mac will be backing up to your NAS or Windows share in no time, all the time.

This tutorial assumes you've got a working NAS you can access on your Mac, or that you've set up Windows to share files with your Mac.

1. Create A Sparse Image

First things first: we're going to make a sparse image, which is a resizable kind of virtual disk. There are a few reasons for this:

  • Time Machine will only write to HFS drives, and this virtual drive is one.
  • Unlike other virtual drives, a sparse image only grows when you add information to it – so it will only take up space on your networked drive as needed.
  • You can set a maximum size for your sparse image, effectively capping how much of your network drive's space Time Machine will ever take up.

There are two main methods to make this image – the first involves the Terminal (commands); the second Disk Utility (GUI).

Open the Terminal, then switch to the Desktop folder:

        cd Desktop
    

Now let's create the sparse image. Here's a command to start with:

        hdiutil create -size 600g -type SPARSEBUNDLE -fs "HFS+J" TimeMachine.sparsebundle
    
create-image-terminal

This will create a 600 GB image named "TimeMachine" – change the size to suit your needs (roughly twice the size of your Mac's storage space is recommended). Thanks to Stephen Morley for the command.

If you'd rather avoid the terminal, don't worry: you can use the Disk Utility instead. Open it, then click the New Image button in the toolbar.

time-machine-create-image

First set Image Format as "sparse button disk image", then set the size you want (setting the size first will probably result in an error message). Give the disk a name (I use TimeMachine in this tutorial), then optionally enable encryption. Save the disk to your desktop.

2. Copy Sparsebundle To The Network, Then Mount It

Head to Finder, and open the network folder you'd like to use for your backup. Drag the sparse image you just created to this folder.

time-machine-on-network

Once everything has copied you can then delete the remaining image on your desktop. Now, double-click the copy of the image on your network share – this will mount it. If everything worked, you should see the new TimeMachine drive in your Finder's sidebar and on your desktop (depending on your settings).

time-machine-sparseimage-mounted

3. Tell Time Machine To Backup To Your Mounted Drive

Now for the magic step: telling Time Machine to use your virtual drive for backups. Open the Terminal and enter this command:

        sudo tmutil setdestination /Volumes/TimeMachine
    

If you named your image something besides "TimeMachine", you'll obviously need to use that name instead.

Let's see if it worked! Head to System Preferences, then open the Time Machine settings. You should see your virtual drive as the default backup destination. Here's how that looks for me, after a couple backups:

time-machine-nas-working

Congratulations! Go ahead and run your initial backup, if you want – it's going to take a while. I recommend you plug your Mac directly into your router with an ethernet cable, instead of using WiFi, and use a program like Caffeine to keep your Mac awake until the initial backup is done.

4. Tell Your Mac To Mount Your Bundle At Boot

So long as your image is mounted, Time Machine will keep backing up. Restart your Mac, however, and you'll need open the image again before your backups can start. If you'd rather not go through the effort, Sean Patterson has a quick AppleScript you can create to mount the drive for you.

time-machine-auto-mount

Paste Sean's script into Script Editor (find it in Applications), then change the names to refer to your network share and sparsebundle. Test the result and save it as an Application if it works.

In Users and Groups, you can add the application you just made to your Startup Items – it will run when you log in.

If you can't get this working, and would prefer a GUI tool for the job, check out Control Plane, which lets you automate mounting your Time Machine driver whenever you're at home.

The One Hangup: Can't Use OS X Recovery

The above process gives you a working Time Machine backup, with one caveat: you cannot use this backup to restore using OS X Recovery. That feature lets you roll back your entire Mac history to a given time, which is useful after a system crash or when you're replacing a hard drive.

In the case of a total drive failure, you'll need to reinstall OS X entirely, then mount the Time Machine drive using the steps above. Once that's done, you can restore your files using the Migration Assistant.

migration-assitant

It's an extra step, but it works.

Apple: Make This Easier!

While I was setting this up, my wife set up the backup feature built into Windows 8 to save her files to the same drive. There were fewer steps, to say the least.

Things could be easier were I to spend $300 on a Time Capsule, which I suspect is what Apple would prefer I do, but I still wish Apple would provide more options for Time Machine drives because with a little work you can use just about anything.

Backups are important, but if you don't have one then you might need some file recovery tools for your Mac if things do go wrong. Trust us – backup your files! You could also opt for online backup services to keep your data safe.

Did the method above work for you? Do you have any suggestion to make things simpler? Let's talk, fill me in in the comments below.

How do you keep your files safe?