www.KevinBurkholder.com

Getting Work Done Through People

Getting People Done Through Work

Friday, March 5, 2010

Mac OSX, Time Machine, and Network Shares

Using a network share or a Network Area Storage device (NAS) with Apple's Time Machine for Mac OS X 10.5 Leopard

Time Machine is the breakthrough automatic backup that’s built right into Mac OS X. It keeps an up-to-date copy of everything on your Mac — digital photos, music, movies, TV shows, and documents. Now, if you ever have the need, you can easily go back in time to recover anything.
http://www.apple.com/macosx/features/timemachine.html

Backups using Time Machine on a Network Volume/Share

I've seen many discussions on many forums about using unsupported network devices and Time Machine - Specifically Network Access Storage (NAS) devices.

In theory, it "should" work. However, your results may vary - and it may depend on your computer, your network, and/or your NAS.

Here are the basic steps needed to get Time Machine to backup to your NAS...

  1. Tell Time Machine to recognize unsupported devices.
  2. Create a sparse-bundle disk image.
  3. Mount the NAS share.
  4. Copy the disk image to the NAS share.
  5. Open Time Machine and select the NAS share as the backup volume.

For reference, here are some specifics but before you start doing this, check out the AppleScript...

Note: I am using a MacBook on an wired and wireless (Airport) network, MacOS X 10.5.6, and a Synology CS407e NAS (firmware version DSM 2.0-0731).

Step 1. Tell Time Machine to recognize unsupported devices.

This is done with a simple Terminal command:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1 
Open Terminal (Applications:Utilities:Terminal.app), past the above line and press return.

You must do this in order to get Time Machine to recognize anything other than "officially" supported devices (i.e. Time Capsule or direct-attach hard drives).

Step 2. Create a sparse-bundle disk image.

  • Open "Sharing" in System Preferences and note the exact computer name
    (mine is "Kevin's MacBook").
  • Open "Network" in System Preferences, click on "Built-in Ethernet" (even if you're not using the built-in ethernet port), click the "Advanced" button, click the "Ethernet" tab and note the Ethernet ID - this is also known as the MAC address.
    (looks something like "00:1d:e1:48:55:1d")
  • Open Disk Utility (Applications:Utilities:Disk Utility.app), click "New Image" and use the following settings:
    • Image Format: sparse bundle disk image (enter this setting first to prevent a possible error when specifying the volume size)
    • Save As: {Computer Name}_{EthernetID}.sparsebundle
      {Computer Name} is the name noted from the Sharing preference, EthernetID is the id noted from the Network preference WITHOUT the colons (001de148551d).
    • Location: Your desktop (for now).
    • Volume Name: Backup of {Computer Name}
    • Volume Size: whatever maximum size you want.
    • Volume Format: Mac OS Extended (Case-sensitive, Journaled)
    • Encryption: none
    • Partition: No partition map

Note: The size of the disk image is most likely less than the size you specify above. In my case, I created a 250 gigabyte disk image and the size of the file was 1.12 gigabytes.

Step 3. Mount the NAS share.

Okay, before we can mount it, we have to create it. I suggest creating a matching share name and user name on your NAS. Give the user exclusive read/write access to the share.

Now in the Finder click the "Go" menu and select "Connect to server...", and enter the url for your NAS:
smb://timemachine@cubestation.local 
In this example, I used the user name I created on the nas (timemachine) and the DNS (or Bonjour) name of the NAS (cubestation.local). I also prefer using SMB over AFP as it is much faster. Using the IP address and/or AFP is similar:
afp://timemachine@192.168.n.n 
You definitly want to use the user name you created specifically for this purpose. You do not need to save this in your Keychain.

Step 4. Copy the disk image to the NAS share.

Drag and drop the disk image you created in step 2 to the share you mounted in step 3.
(you can delete the disk image from your local machine when it's done).

Step 5. Open Time Machine and select the NAS share as the backup volume.

Click "Choose Backup Disk" or "Change Disk" (if you used Time Machine before) and select the NAS share you mounted in step 3.

Enter the user name and password of the user you created on your NAS for this purpose. Time Machine will remember this user each time it runs.

Done

And that's it. Your backup should start running after 2 minutes. However, there are a couple of potential problems. Mostly due to settings in the disk image that can't be controlled through Disk Utility...

When Time Machine runs, it creates files within the disk image as it stores the data being backed up. These files do not correlate to the individual files on your computer, rather they are 8 megabyte "bands". As Time Machine needs more space, it creates more bands. When the disk image is full, it removes bands to create new ones (or maybe it just reuses them, I don't know). But consider this: With bands of 8 megabytes, a 250 gigabyte backup results in 32,000 bands. Since the disk image is being mounted across the network, accessing this many bands within the disk image is, at best, tedious.

While the disk image is mounted, Spotlight will try to index it - unneeded and degrading to performance (32,000 bands of data).

A beter way of creating the disk image is via hdiutil in Terminal using this command:
hdiutil create -size 250g -type SPARSEBUNDLE -nospotlight 
-volname "Backup of {Computer Name}" 
-fs "Case-sensitive Journaled HFS+" 
-imagekey sparse-band-size=524288 
-verbose "{Computer Name}_{EthernetID}.sparsebundle" 

This will create a 250 gigabyte disk image with a band size of 256 megabytes and suppress Spotlight from indexing it.

Technically, band size is based on the sector size of the disk. Since most disks have a sector size of 512 bytes (1/2k), specifying 524288 (512 * 1k) results in a band size of 256mb.

 

Now that you know some of the details, click on the "AppleScript: TimeMachine on NAS" tab (above) for an AppleScript that will help accomplish some of these steps.

Further Reference:

TimeMachine on NAS

Download:
TimeMachine_on_NAS.zip

Interested in using this software in your project? Contact Kevin at KBurkholder@EarthAsylum.com
Creative Commons License This work is licensed under the Creative Commons GNU-LGPL License.
Licensing & Registration
 
Donations are greatly appreciated and help fund further development and maintain the LGPL licensing.
Follow me on Twitter for software updates, releases and announcements.

TimeMachine on NAS is an AppleScript application used to accomplish some of the steps outlined on the "Overview: TimeMachine on NAS" tab.

Specifically, it will:

  • Tell Time Machine to recognize unsupported devices.
  • Get the computer name and the Ethernet ID.
  • Create the sparse-bundle disk image on the desktop of your Mac.

Here are the complete steps involved in setting up Time Machine to use a network share:

  • Create a unique user name on your NAS.
  • Create a unique share on your NAS.
    (I suggest that both user and share are the same i.e "timemachine")
  • Give the user exlusive read/write access to the share.
  • On your Mac, run TimeMachine on NAS to create the sparse-bundle image.
  • Connect to your NAS share using the user name created in step 1.
    You do not need to remember your username in the keychain.
    (I recommend using smb over afp to connect - it's faster:
    Finder | Go | Connect to Server
    smb://nas_ip_address_or_dns_name)
  • Copy the sparse-bundle disk image to the NAS share.
  • Delete the sparse-bundle disk image from your desktop.
  • Open Time Machine and click "Choose Backup Disk" or "Change Disk",
    select your NAS share, click "Use for Backup"
    enter your username and password for Time Machine to remember.

Note: You can use the same share (but not the same disk image) to backup multiple computers. This script must be run for each computer.

To use TimeMachine on NAS, download the zip file (link above right), unzip the file and double click on "TimeMachine on NAS.app" (note that the extension (.app) may not appear in the Finder).

When you run TimeMachine on NAS, it will ask you for the maximum size of the disk image (in gigabytes) and the size of the bands within the disk image (in megabytes). It then uses shell (terminal) commands to retrieve the computer name and ethernet id and to create the disk image.

Note: Band size is based on the sector size of the hard disk. This script assumes a sector of 512 bytes and computes the band size approprietly. If the sector size of your disk is different, the band size may not be what is expected.





Disclaimer: Although this procedure has worked, I can not guarentee, nor do I make any claims or accept any responsibility in regard to the reliability of your backups. I have not tested the ability of Time Machine to restore files or complete systems after having backed up using this method. This is an unsupported method of using Time Machine and should be consider suspect untill and unless you have proven otherwise, using your own equipment, software, and network.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 Powered by  eac::Framework 

eac::Framework is a lightweight PHP & JavaScript framework for Web 2.0 Applications and E-Commerce systems.

For more information, visit http://www.KevinBurkholder.com/framework

eac::encryption, eac::session, eac::keychain, eac::dataobjects, eac::tracker, eac::sourcing, eac::authentication, eac::filter, eac::formgen, eac::caching, eac::mailer, eac::download, eac::error, eac::streams and more.

www.KevinBurkholder.com
Strengths Based Performance Management
EarthAsylum Consulting
The EarthAsylum Leadership Circle