How to Create a Time Machine Backup to a Network Drive

Let’s say you have a home NAS (Network Area Storage), a router with a hard drive, or even an old Windows machine with a lot of disk space lying around. You want to make use of this disk space to store your Time Machine backups. You open Time Machine Preferences and the only way you can add a non-local disk is via a Time Capsule or AirPort-connected storage. Now what? If this is your problem and you have upgraded to Mac OS X Lion, there is a workaround… Keep reading.
The reason why Time Machine Preference Pane doesn’t show network drive is likely the Mac Developer’s mantra: keep simple things simple and complex things possible. Novice users, by definition, are inexperienced — they’re likely haven’t gone through the pain of losing data and discounted the value of backups. Thus to not complicate things more and make it easy for most users (especially novices) Time Machine’s preferences only cater for the two common cases:
  • Directly-attached external storage (via USB, Firewire, or Thunderbolt).
  • Time Capsule or Airport Base Station attached storage.
But with Mac OS X 10.7, Apple have now made more advanced cases possible. As with most advanced stuff, you will need to open up Terminal to do it. The secret? The new tmutil command.
Back to the HOWTO. In order to create a Time Machine backup on a network folder  you need to follow these three steps:
  1. Create a HFS+ disk image, preferably sparse disk image, and place the disk image file into its destination folder/server where it will live. It shouldn’t matter whether it is SMB (Windows) or AFP (Mac) shared folder as long as your Mac can write to it.
  2. Mount the disk image and use the tmutil command to tell where is it. Make sure that the disk image is in it’s permanent home before you use tmutil (Also, don’t change the server name or shared folder name after Time Machine use it as your backup volume).
  3. Tell Time Machine to start the backup process to make sure it works.
Still not clear? Here comes the walkthrough

Creating the Disk Image

  1. Open Disk Utility
  2. Click on New Image
  3. Set a large enough size for the disk image. Ensure that the Format is “Mac OS X Extended (Journaled)” (in other words, this will be HFS+, the  Mac’s native filesystem) and the Image Format is “sparse bundle disk image“.

    Time Machine Disk Image Settings
  4. You can set Encryption if you want but not necessary. On the other hand,encrypting the disk image is a good idea since you’re going to put it on a network that can potentially be accessed by others.
  5. Save the disk image to the shared folder. Alternatively you can save the image locally and then move it to the destination folder on a server.

Tell Time Machine to use the Disk Image

  1. Open Finder
  2. Navigate to the shared folder which you put the new disk image.
  3. Double-click on the disk image to mount it. You should see the new volume in the Finder’s sidebar
  4. Open Terminal and enter the following command :
    sudo tmutil setdestination /Volumes/{mounted-disk-image}
    Be sure to replace {mounted-disk-image} with the appropriate name for your new disk image. You will be prompted for your password, this is normal.

Do a Test Backup

  1. Click the Time Machine icon in the Menu Extras area (that’s the upper-right side of the screen) and select “Back Up Now”.
  2. Wait for 10 minutes or so for Time Machine to do its thing
  3. Open Finder, navigate to the mounted disk image, and ensure that Time Machine have created the “Backups.backupdb” folder and there is a folder inside it with the same name as your computer.
So that’s just about it. You can also use this method to save backups to non-Mac drives, like NTFS drives, if you have the appropriate drivers installed to write to those filesystems (hint: MacFUSE+NTFS-3g or Tuxera’s NTFS driver). For more information on the tmutil command, type man tmutil at the Terminal.
Advertisements

How to restore data from Time Machine in Mountain Lion

Restore a single file or folder

If you’re looking for a certain file or folder, start by connecting the external drive that you use for Time Machine backups or by making sure that you can connect to your Time Capsule. Click the Time Machine item in the menu bar at the top of your screen (it looks like a clock with an arrow running counterclockwise around it), and choose Enter Time Machine. Here, all of your saved backups will appear in chronological order. Use the visual timeline on the right side to scroll through your backups and look for specific items or folders. Older dates are indicated in pink on the timeline; the most up-to-date data on your Mac is indicated in white. (You’ll see the word ‘Now’ in bold, white letters on the timeline.)
Not sure which backup might hold the last copy of your missing file? Try running a Spotlight search in Time Machine based on keywords. You’ll see a search field in the upper right corner of each Finder window in the Time Machine view. Type in the file name or keywords from the file, and Spotlight will search through your backups to find the latest copy.
Not sure where to find the file you need? You can perform a Spotlight search in Time Machine, using the search field (circled).
Once you think that you’ve found what you’re looking for, use OS X’s Quick Look to make sure: Select the file and then press the spacebar to view the file without having to launch its parent application.
Preview a file before you restore it by using OS X’s Quick Look feature.
Select the file or folder, and press the Restore button. The file will automatically be copied to your desktop or to the file’s original folder. This may take some time, depending on the size of the transfer.

Restore an entire system

Sometimes you may want to restore your entire system from a backup—say, in the event of a crash or when your computer is misbehaving and you’d like to dial the clock back to a kinder, gentler time. If that’s the case, first connect your Time Machine drive. Then start up your Mac from the Mountain Lion recovery partition by pressing (and holding down) Command-R at startup. This launches Recovery Mode, a portion of your drive that Mountain Lion treats as a separate volume. It includes a few essential utilities for restoring files in case of a problem. For this approach to work, you must have a complete Time Machine backup that includes all system files.
The Mac OS X Utilities window appears. Select Restore From Time Machine Backup. This command will erase the destination drive—your Mac—so use it only if you’re restoring an entire volume to its original source or to a replacement drive. (Read the next section for setting up a new Mac or transferring data between Macs.)
Click Continue until you reach the Select a Backup Source window. here, select your Time Machine drive and click Continue. In the Select a Destination window, choose your Mac’s hard drive. (Using Recovery Mode erases your Mac’s hard drive before restoring from Time Machine; but once the process is finished, you’ll be able to log in and use your Mac normally).

Transfer data between Macs

Let’s say that you bought a new Mac and want to transfer all of the data from your old system to it. Or imagine that you simply want to transfer data from one Mac to another. Time Machine can help here, too, but with the assistance of another built-in Mountain Lion utility called Migration Assistant.
Use OS X’s Migration Assistant to transfer data from a Time Machine backup to a another computer.
Once your backup drive is connected, launch Migration Assistant (in your /Applications/Utilities folder). A Migration Assistant window will appear and ask how you want to transfer your information. Choose the From another Mac, PC, Time Machine backup, or other disk option and then click Continue. You may be prompted to enter your administrator’s password. Do so, if necessary, and clickContinue.
Next, you’ll be asked to quit other applications. Do so, and click Continue. In the next window, select the From a Time Machine backup or other disk option and click Continue.
Select your backup drive and enter a password for it, if necessary. Then choose which items you’d like to migrate (chances are, your choice will be to move everything). Click Continue, and your files will begin to transfer.