Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Time Machine: Setup on and restore from a NAS device Apps
This hint explained how to set up a network attached storage (NAS) device as a Time Machine backup. To make this process easier, I've created an AppleScript that makes the creation and setup a one-step process -- just drag and drop your mounted NAS onto the following AppleScript to ready the drive for Time Machine use.
on open names
  set volumeName to names as text
  set macAddress to (do shell script "ifconfig en0 | grep ether | tr -d '\\011' | sed s/ether// | sed 's/ //g' | sed s/://g")
  set hostName to (do shell script "hostname -fs")
  tell application "Finder"
    set theSize to round (((capacity of startup disk) / 1024 / 1024) / 1024)
  end tell
  
  do shell script "defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1" with administrator privileges
  
  do shell script "sudo hdiutil create -size " & theSize & " -type SPARSEBUNDLE -nospotlight -volname \"Backup of " & hostName & "\" -fs \"Journaled HFS+\" ~/" & hostName & "_" & macAddress & ".sparsebundle" with administrator privileges
  do shell script "mv ~/" & hostName & "_" & macAddress & ".sparsebundle /Volumes/" & volumeName & "/" with administrator privileges
  
  tell application "Finder" to eject volumeName
  
  tell application "System Preferences"
    activate
  end tell
  
  tell application "System Events"
    tell application process "System Preferences"
      set frontmost to true
      click menu item "Time Machine" of menu "View" of menu bar 1
    end tell
  end tell
  
end open
(You can also download the script (and an application bundle version of it) from this entry on my site.)

After using the script on the drive, open the Time Machine System Preferences panel. Now you should be able to use your network volume as a target disk for Time Machine backups. Read on to find out how to then restore from this disk, assuming you've had a complete hard drive failure and you're starting from scratch with the OS X installation disc...



To restore from your NAS, first insert your Mac OS installation disk and start your Mac. After the installer loads, choose Terminal from the Utilities menu, and mount your external disk. The Installer enables (by default) the DHCP for interface en0; if the NAS is configured for DHCP, then it will get a reachable IP address. To discover that address, try to ping the whole submask using the ping tool:
$ ping 169.254.255.255
PING 169.254.255.255 (169.254.255.255): 56 data bytes
64 bytes from 169.254.101.39: icmp_seq=0 ttl=64 time=0.299 ms
64 bytes from 169.254.101.39: icmp_seq=1 ttl=64 time=0.368 ms
64 bytes from 169.254.101.39: icmp_seq=2 ttl=64 time=0.368 ms
--- 169.254.255.255 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.299/0.345/0.368/0.033 ms
The address that responds to your ping (169.254.101.39 in the above example) is the NAS. Let's make a mount point for our disk:
$ mkdir /Volumes/myNAS
Next, you have to mount the NAS in your freshly created mountpoint:
$ mount -t afp afp://admin:admin@169.254.101.39/myshare /Volumes/myNAS
Be sure to specify the entire address of your NAS server, including the resource (myshare in the above example). Finally, you have to notify the Finder about your newly-mounted device. Start by getting a list of the mounted devices with disktool -l. Look for the rows beginning with:
***Disk Appeared ('something',...
Find the entry containing your NAS mountpoint. Write down the first entry and use it as a parameter (replacing your_entry) in the following command:
$ disktool -m your_entry
Close Terminal and proceed as normal with your installation. When asked to resume from a Time Machine backup, choose the network disk.

[robg adds: The above script is recreated here just in case the original linked version ever vanishes. The linked version may contain newer code, though, so check there first. On the linked page, you'll also find screenshots and more detail on the entire process.]
    •    
  • Currently 3.05 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (21 votes cast)
 
[24,719 views]  

Time Machine: Setup on and restore from a NAS device | 11 comments | Create New Account
Click here to return to the 'Time Machine: Setup on and restore from a NAS device' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Time Machine: Setup on and restore from a NAS device
Authored by: a153957 on Nov 10, '09 07:44:18AM
set theSize to round (((capacity of startup disk) / 1024 / 1024) / 1024)
Is this still valid for Snow Leopard? should the numbers not be 1000 since it uses ther 'other' definition of GB/GiB etc..
---
153957 Photography
- - - - - - - - - - - - - -
http://arne.delaat.net/


[ Reply to This | # ]
Time Machine: Setup on and restore from a NAS device
Authored by: haralds on Nov 10, '09 08:30:18AM

Yes. The values can be of arbitrary size, but need to be greater than the largest expected backup.



[ Reply to This | # ]
Time Machine: Setup on and restore from a NAS device
Authored by: MediaPlex on Nov 10, '09 09:22:14AM

Hello. I have two NAS drives @ 1GB each (Linksys NAS200). Its formatted via the NAS, so its not NTFS or FAT or even HFS/+, etc. Not sure what it is but it has journalling set ON. One drive is my wife's and one is mine. We have two Windows PCs and one iMac (10.6.2). We currently back up the Windows PCs via Acronis to each of our respective drives We both share the iMac with each our own user account. What I'd like to do is set up Time Machine to back up the entire iMac drive to "my" NAS drive (DISK2) on the NAS but I have some questions first: Will this overwrite my Acronis backups? (will Time Machine use the entire DISK2 or will it use the particular folder I tell it to?) Does it matter that its not HFS or HFS+? Are there any other concerns about "sharing" this one particular NAS drive my Windows backups and the iMac's Time Machine?

Thanks!



[ Reply to This | # ]
Time Machine: Setup on and restore from a NAS device
Authored by: everkleer80 on Nov 10, '09 01:33:44PM

In answer to your question, you should be able to do this and it should not affect your existing data, but as others are mentioning, this is not advisable if you care about having a safe, reliable backup for your Mac. So you are only debating between this solution and having no backup at all, then I'd say yes this is possible and will be better than nothing. (See my comment below.)



[ Reply to This | # ]
Warning: unsupported Time Machine volumes for backups can be dangerous
Authored by: dbs on Nov 10, '09 09:57:16AM

I'll repeat my warning from previous hints in this regard: if you care about the integrity of your backup don't use unsupported volumes.

For time machine to work reliably across network dropouts and computer wake/sleep events in the middle of a backup, it relies on the journaling system of HFS+. However, for this to work on a disk image, the file server must support completely flushing writes to disk on command. (Otherwise the contract of a disk journal is broken and the file system can be corrupted.) The file servers that do not show up automatically in Time Machine are the ones that do not support this feature, so by tricking Time Machine to work with them, you are putting your backup at risk.

Basically, if you care about your backup not getting corrupted, don't use a network volume that doesn't show up automatically.



[ Reply to This | # ]
Warning: unsupported Time Machine volumes for backups can be dangerous
Authored by: Anonymous on Nov 10, '09 12:15:08PM

Hey, it took this long and this much effort for people to start doing backups. You think they care about restores?



[ Reply to This | # ]
Warning: unsupported Time Machine volumes for backups can be dangerous
Authored by: everkleer80 on Nov 10, '09 01:17:54PM

Haha you're probably right for the most part! Now that I have the feature, I use it, but my data's not all THAT important so if the backup helps me out then great, if it gets corrupted or something then it's not a huge deal. And I'd be willing to bet that most people think like that (and If their backups are critical then I'm sure they're not using Time Machine!)



[ Reply to This | # ]
Critical Backups and TM
Authored by: rodneyweston on Nov 10, '09 02:19:49PM

Suggestion: If their backups are critical they are not JUST using Time Machine. I find TM very effective for what it does (especially restoring old versions of files which I have stupidly written over - such as last months bank reconciliation).

However, for my system backups, I have two SuperDuper! clones... which is faster and (reportedly) more reliable for a full system restore using TM.



[ Reply to This | # ]
Time Machine: Setup on and restore from a NAS device
Authored by: GianPaJ on Nov 10, '09 03:01:24PM

I would like to know why i'm getting an error after i start the backup and copy the sparsebudle
I've done the sparsebundle using this command

sudo hdiutil create -size 74g -type SPARSEBUNDLE -nospotlight -volname "Backup of GianPas-MBP" -fs "Journaled HFS+" ~/GianPas-MBP_xxxx.sparsebundle

my snow leopard partition on my MBP is 285GB but i've excluded all non important data so i just need to backup less than 60GB.
the partition on my FreeNas (afp) has the 76Gb

can somebody explain me why? thx



[ Reply to This | # ]
Multicast Ping
Authored by: punka on Nov 13, '09 07:45:53PM

When I pinged 169.254.255.255, I did not get any responses.

I believe the multicast IP is actually 224.0.0.1. Pinging that IP got responses back from all of the devices on my network, so long as they support multicast. I don't know if NAS machines will respond.

You could always find the IP of your NAS from any other computer on the network.



[ Reply to This | # ]
Time Machine: Setup on and restore from a NAS device
Authored by: dimidimi on Nov 14, '09 07:16:49AM
This looks very helpful for my Iomega NAS! I tried it in my MacBook Pro MacOS 10.6.2 but the script ended with the message: access for assistive devices is disabled. Then I tried again and it failed at the mv command with a directory is not empty message. Could anyone share any hint? Is there any way to take back the changes performed by the script?

[ Reply to This | # ]