This how-to describes how to use shares on your local network as backup volumes for Apple’s Time Machine. This is interesting especially if the network is wireless! And different from other hints on the web, this article tells you how you can keep your existing backups for that. Apple sells this functionality with its Time Capsule products (but they do not support the reuse of existing backups).
If you don’t want to read the whole article and know the Terminal well, here it is in very compressed form:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
sudo hdiutil create -srcdevice /dev/<diskXsY> -format UDSB -fs HFS+J -volname Backups -layout NONE /Volumes/<your network share>/.<your ethernet macaddress without colons>
Many posts on the web helped me to get this working and I would like to thank especially Florian Kruse for his article on this topic. If you are setting up Time Machine for the first time and would like to do that over network, read his article.
What you will need:
- Time.
- Some kind of computer (Mac, Linux, Windows, …) that you have access to and that is connected to your network. I will reference to it as the server from now on.
If it’s possible to connect external hard drives to your router, you can of course use this as your server as well.
- A network share on the server (the place where your backups will be kept). This can also be your existing external drive where you keep your backups right now.
- The same amount of free space that your existing backups take up. And it must not be on the same partition on which the existing backups are stored right now!
One way to find out how much space they use is to open the Disk Utility (under /Applications/Utilities), select the backup volume and see what it says at the bottom of the window.
This is because you will need to create a copy of your backups (see next section why). If you’re planning to use your external hard drive as your backup volume, you will need to create the copy elsewhere, format your backup volume and then move the copy back.
How it works:
If you connect an external drive (e.g. over USB) to your Mac and make your backups, the files, folders and Time Machine config files are naturally written onto the partition you chose.
But if you use Volumes that are mounted over network, Apple decided to use another technique. They create a SparseBundle file on the network drive (
read here what it is). This file is a kind of disk image and contains all the data we would have on a USB drive. It is then mounted on your Mac and is used for backups.
Now you could say: “Why this double trouble”? There are some reasons why we want this!
The best thing is, that it has the HFS+ Journaled filesystem! This way we can use any network share without having it to support HFS+ Journaled. Maybe you have tried to connect your USB drive to the server before. What happened? Right you can’t mount it writable because HFS+ Journaled isn’t fully supported by Linux, yet.
Another advantage is, that it only takes up the space it needs! You don’t have to create a fixed partition that takes up hundreds of gigabytes even if it’s not used. Nevertheless it can be unmounted (which Time Machine actually does) every time the Backup is not needed.
Yet another important reason: The files on your Mac can have complicated extended permissions and hard- and soft-links etc.. Network shares like Samba(Windows share) or FTP do not support these high fidelity file permissions and types. So you wouldn’t be able to use them as backup volumes.
Before you start:
Make sure your Mac can connect to the network share on the server and has read and write permissions. The used protocol is irrelevant (see section above why).
I cannot explain how to set up the network share in this article since and is different for each platform and type.
Warning: Be careful with your backups! I myself had a head-crash while my backups were broken. Yes, it is possible! So always know where your backup files are!
How to do it:
- Turn Time Machine off so it doesn’t interfere.
- Creating the SparseBundle (the interesting part)
As I said before, you will need empty space in size of your backups where you can save the bundle file. If it’s on the network share, great! That’s where it should be. If you’re planning to use your external hard drive as your network share, you will need to create the bundle file elsewhere, delete your backups and then move the bundle there. “Elsewhere” can also be on the external drive as long it’s on a different partition.
- Find out the backup identifier
To do so, in Terminal (/Applications/Utilities) enter
ls -la /Volumes/<nameofyourtimemachinevolume>
It will show you a list of files. Find the one that starts with a dot and ends with a twelve digit hex-code e.g .0019e56f322a Write down this string somewhere.
- Find out the device file of the backup volume. Therefore open the Disk Utility (/Applications/Utilities). There, right-click (control-click) on the backup volume and open the Information window. The device filename is the name after
Disk Identifier. It should be something like disk1s1. Again, note it.
- Unmount the backup volume
In Disk Utility, select the backup volume and hit unmount. Do not eject the disk!
- Create the SparseBundle by opening the Terminal (/Applications/Utilities) and entering the following line:
sudo hdiutil create -srcdevice /dev/diskXsY -format UDSB -fs HFS+J -volname Backups -layout NONE /path/to/free/space/filename
Where diskXsY is the Disk Identifier you found in 3.2 and /path/to/free/space is the location where you would like to save the bundle file to. When it’s done, you will find a file named filename.sparsebundle there.
Hint: This operation takes a long time. It took about an hour for my 75 GB backup.
- Optional: If you did not create the file on the network share, move it there now (in Finder hold down the option key for moving instead of copying). If you would like to use your existing backup drive as the network share, you will probably need to format it first (not as HFS+ Journaled!) and then move the sparsebundle file there. To format it, use Disk Utility.
- Name the file right
The .sparsebundle file must have the same name you found in 3.1. Finder won’t let you rename files to names that start with a dot. So open the Terminal again and goto the location where you created the file. There, type
mv filename.sparsebundle .0019e56f322a.sparsebundle
Of course using your values instead.
- Enable Time Machine for network volumes
By default, Time Machine won’t let you choose volumes that are mounted over network. To enable it type the following in the terminal:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
- Turn Time Machine on
Make sure you have mounted the network share with the sparsebundle file in it (and it’s not in subfolders). Then open Time Machine preferences, click “change disk…” and choose the network share.
Leave the settings window open to see if it worked. If so, it will start to backup. When it finishes, you will be able to use your old backups!