OSX Timemachine and Samba/Windows share

April 27, 2008

Hello all,

This is a tutorial on how to use OSX 10.5.2 time machine with a Linux Server/Windows Server/Windows Share. I hope that you have already set up your samba server or windows share on the network if not please read the Samba-Howto or windows file sharing. Also make certain that the shares have read write access! Now create a directory for each OSX computer that you will be using time machine on the server of windows share. I like to use the name of the OSX computer as the directory. My computer is called Hcomp ( you can change the name of your computer in OSX by going to System Preferences->Sharing) so I create a directory called Hcomp on my server.

Now we need to make it possible for timemachine to access our folders on our network. Open up Terminal (Finder->Applications->Utilities->Terminal) and enter in the command ‘defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1′.

It now should be possible for time machine to show the samba shares and other non OSX shares, but before we can use these shares we have to mount them. Open Finder and click on G0->Connect to server in the finder menubar at the top. For the Server enter in smb://yourusername@yourservername_or_ip/YourMacOSXComputerName. For example my server is called ‘Bob’ and my OSX computer name is called ‘Hcomp’. The username and password was set up by reading the samba or windows file sharing like. So lets say my my username to access the server is called ‘willy’ and the password is ‘wonka’. I would then enter in for the server address smb://willy@Bob/Hcomp then I would click on the connect button. The prompt will ask you for the password. Enter that in also.

Now open time machine (Finder->Applications->System Preferences->Time Machine) and click on change disk. If you have mounted the directory correctly it should show up when you click on Change Disk. Select the directory that you have just mounted. For me I would select Hcomp. Now turn time machine on and it will wait 2 minutes before running the back up. If it doesn’t backup automatically then make sure that the ‘Show time Machine status in the menu bar’ is checked and click on the round clock on the menu bar at the top of the OSX screen and click on back up now. it now should run for a little bit and give you an error saying that it cannot create image error. This message is fine because it created a file that we needed for this to work.

Next Open the terminal (Finder->Applications->Utilities->Terminal) and type in ‘ifconfig en0 | grep ether’. After hitting return the command should have given you something like ether 00:00:45:12:8a:91. Write this number down without the colons. Now you have to ask yourself how much space to allocate to the time machine back up. This depends on your setup and how much space you have on your server. I choose 100GB my mac only has 100GB partition. Now the next command will create the sparsebundle that time machine needs to make the whole thing work.

‘hdiutil create -size 100g -fs HFS+J -volname “TimeMachine Hcomp” Hcomp_000045128a91.sparsebundle’

Do not type this in to the terminal yet without modifying it to your settings. Basically after the ‘-size 100g’ is the maximum size that time machine can be. ‘-volname “TimeMachine Hcomp” can be changed to ‘-volname “anything that you want”‘ but the last part of the command is important. Remember you wrote down the numbers for your mac ether 00:00:45:12:8a:91.
Well for the last part replace ‘Hcomp with you computer name and _000045128a91 with the number that you wrote down.

The last paragraph might be confusing so here is another example.
Servername: Server
OSXComputerName: OSX
MAC: 00:00:1F:12:82:92
Size of time machine space : 200GB
command ‘hdiutil create -size 200g -fs HFS+J -volname “OSX Backup” OSX_00001F128292.sparsebundle’

Now you should a file like Hcomp_000045128a91.sparsebundle or OSX_00001F128292.sparsebundle on your computer. Now copy this file to the server by issuing ‘cp -R Hcomp_000045128a91.sparsebundle /Volumes/Hcomp’ or ‘cp -R OSX_00001F128292.sparsebundle /Volumes/OSX’ but remember to replace sparsebundle with your sparsebundle or you will get an error. If everything worked correctly click on the time machine button at the top (the round clock icon on the menu bar) and do backup now. It should run and will take at long time the first time you do this.

Happy travels through time.

Entry Filed under: OSX Tutorials, Uncategorized. Tags: , , , .

54 Comments Add your own

  • 1. dlipton  |  September 3, 2008 at 6:11 pm

    fantastic it worked for me!
    very clear instructions thanks for sharing !

    Reply
  • 2. bharris  |  September 20, 2008 at 11:49 am

    Of all the asinine solutions for this problem out there on the web, yours is the only one that worked! Thank you for being so clear and straightforward.

    Reply
  • 3. Hans  |  September 25, 2008 at 6:02 pm

    Thanks for the excellent description, thanks to you I finally got it working! Only question I still have: how reliable is this setup, obviously not supported by Apple…

    Reply
  • 4. hupio  |  September 26, 2008 at 3:36 am

    Hm.. I don’t know how reliable this setup is, but hopefully apple won’t disable this feature.

    I am glad that everyone has gotten it to work.

    Reply
  • 5. Casey  |  September 26, 2008 at 4:04 am

    Worked great thx! I can’t stress enough that the machine name part of the sparse bundle is super important ;)

    Odd thing is if you watch the share from the windows side when time machine initially sets it up it creates the files. I’m not sure what it is that time machine just isn’t able to get done on it’s own

    Reply
  • 6. chuc  |  September 29, 2008 at 9:21 pm

    I found that the -volname flag always caused an error, but that it was safe to drop it

    Thanks!

    Reply
  • 7. no  |  October 5, 2008 at 7:14 pm

    On iMacs, it’s likely to be en1 that you need to get the MAC address for.

    Reply
  • 8. Francis  |  October 7, 2008 at 5:10 pm

    can you do a full restore from the install disk? i’m about to send out my macbook for repairs.

    Reply
  • 9. Pär  |  October 8, 2008 at 7:48 am

    Thanks for a great description! On my system (10.5.5) the -volname did not accept names containing a space i.e. “TM macpro” gave error ‘only one image can be created at a time’ while “TMmacpro” did the job.

    Reply
  • 10. Sumin  |  October 16, 2008 at 9:56 am

    It works. Thanks a lot!

    Reply
  • 11. Darren Hoch  |  October 20, 2008 at 2:13 am

    I finally got this to work. The -volume is not required. I tried to use a pre-existing samba share name and kept on getting “Unable to mount disk”. The absolute key here is that you create a samba share that is the same exact name as your mac computer. Also, regardless of whether you use en0 (wired) or en1 (wireless) the TM uses the ethernet address of en0. I am currently backing up my laptop over wireless after 10+ attempts.

    Reply
  • 12. DI  |  October 31, 2008 at 8:19 pm

    Please Place a DIGG button for this article!!!!!

    Reply
  • 13. RichB  |  November 2, 2008 at 7:56 am

    I can also confirm you need to specify en0, even if you’re not using it.

    Reply
  • 14. Pete  |  November 4, 2008 at 6:04 pm

    I’m on a Macbook Air. It only has the wireless interface on en0. I have tried all of the suggestions in this thread. My shared folder is a samba share on a linux system. The thing that made it work for me was dropping the -volname parameter, otherwise I was just getting errors about mounting. Thanks for this thread and all of the contributions in the comments!!!

    Reply
  • 15. ritorujon  |  November 6, 2008 at 5:29 am

    Looks great! Can’t wait to try it:-))) Thanx a lot!!!

    Reply
  • 16. ritorujon  |  November 6, 2008 at 5:44 am

    I’m just a little bit curious…What about right attributes? Are they backed up somehow on samba too, since Samba doesn’t have same ACL attributes as HFS+???

    Reply
  • 17. Rik  |  November 29, 2008 at 5:02 pm

    Hey man, after a few frustrating hours. I stepped away, googled and here I am. Thanks so much, it worked the 1st time for me.

    Reply
  • 18. Jeff Dempsey  |  December 1, 2008 at 6:40 am

    THANK YOU!!!

    For some help on some of the ethernet MAC address and computer name, it may be helpful to have the Console open on, and set to LOG Database Queries > All Messages. Then you can see what Time Machine does when it tries (and fails) to create the original sparsebundle file. (It actually fails during the Journaling creation on my iMac)

    For the user with a space in the computer name, use quotes around the filename, such as with mine, I did
    hdiutil create -size 300g -fs HFS+J -volname “Time Machine Jeffs imac” “Jeffs imac_02204159eac1.sparsebundle”

    and when copying, I just put quotes around the name as well…

    Again, I would have the console (Applications -> Utilities -> Console open, and watch what Time Machine does. It makes Hupio’s AWESOME DIRECTIONS even better.

    HTH,

    Jeff
    (I’ve had the iMac for a week now, and I LOVE it!, after 20 years of IBM-ness…

    Reply
  • 19. Aaron  |  December 5, 2008 at 6:18 am

    Regarding the “only one image can be created at a time” error, I found this was from copying and pasting the command from a wordpress blog that was using curly quotes. Swap those out for regular quotes and it’s fine.

    Reply
  • 20. Rufus Buschart  |  December 6, 2008 at 2:10 pm

    Thank you very much! It works very well!!!

    Reply
  • 21. Tesso M Costa  |  January 7, 2009 at 7:10 pm

    Thanks… i was trying to make it work on a macbook over the airport.. the thing is.. it only worked when i used the -volname and the mac address i used the ethernet even using the airport… wreck… who knows why… i believe the problem was the mac that i was using from the airport… no the ethernet.

    btw.. i did it using a smb share from a linux machine, (yes.. hit me hard, i desirve it… but i was just testing… ) now ill make the real deal using afp on linux or even nfs… dunno yet.

    Reply
  • 22. Me  |  January 8, 2009 at 2:07 pm

    Thanks a lot! It worked great! Only had a problem with volname with spaces.

    Reply
  • 23. Jeremie  |  January 12, 2009 at 1:13 pm

    On a MacBook Aluminum, specifying the mac adress of the ethernet rather than airport was necessary even though backups will be done over wireless.

    Reply
  • 24. David Vannucci  |  January 13, 2009 at 7:46 am

    When I create the image I get the error “hdiutil: create failed – No space left on device” Do I have to make the image size = free space remaining on the disk?

    Reply
  • 25. bombcar  |  January 22, 2009 at 3:37 am

    I was able to make a 500g volume on a 300g disk before copying it over (everything seems to be working fine) – are you sure you have .sparsebundle at the end correctly specified? Paste the exact command line used and check it.

    Reply
  • 26. joe  |  January 24, 2009 at 3:51 am

    Thanks for the great article.

    Easy to follow and had 100% success with this.

    Now I just have to upgrade my ubuntu box’s RAID5 so I’ll have enough room to let TM complete it’s backup!

    Reply
  • 27. recon  |  January 24, 2009 at 4:13 am

    Worked perfect after removing the -volname and ensuring the SMB share was named exactly the same as my Mac’s computer name.

    MacBook Pro backing up to a Maxtor Central Asis 1T NAS

    Thanks for this post and all the comments!

    Reply
  • [...] mais qui nécessite normalement d’acheter le couteux boitier Apple. Autre solution ici [ http://hupio.wordpress.com/2008/04/27/osx-timemachine-and-sambawindows-share/ ] avec Samba qui marche chez moi. Si par contre j’ai le malheur de couper le réseau durant [...]

    Reply
  • 29. rswillems  |  February 1, 2009 at 8:16 pm

    Super! It worked fine with me, at least initially. Subsequent back-ups get the “the backup disk image could nog be mounted” error. Any solution?

    Reply
  • 30. salvaro  |  February 8, 2009 at 6:19 pm

    great! works fine for me. thanks for sharing.

    Reply
  • 31. JF  |  February 10, 2009 at 7:59 pm

    Thanks for this info. Been looking for a solution like this when Iscsi didn’t work.

    Reply
  • [...] I’ve been messing with iSCSI quite a bit lately. I thought I’d enable it on my Ubuntu Linux server, since I have quite a bit of storage space there. My goal was to connect our OSX computer via iSCSI in order to present a 100GB disk to it for use with Time Machine, as  I didn’t have a spare external drive to use for this purpose.  Try as I might, I just couldn’t get ISCSITARGET working reliably on Ubuntu. Ultimately I gave up. Luckily I stumbled acorss this great article on how to use SMB (windows) shares on your network as Time Machine disks.  Read more here [...]

    Reply
  • 33. stmo  |  February 16, 2009 at 7:46 pm

    Thank you !!
    First instruction i found that is really clear and working from a Mac OSX 10.5.6 to a Windows 7 computer.

    Reply
  • 34. Steve  |  February 17, 2009 at 8:42 pm

    Just tried this out and I’m currently making the time machine backup!

    Finally putting my windows pc to some good use :P

    Thanks for the great tutorial.

    Reply
  • 35. Chris  |  March 14, 2009 at 12:07 am

    How does this work with a full restore? Can you simply copy the time machine (sparse bundle) file(s) from the Windows box to an external drive and do a full restore that way?

    Reply
  • 36. Morten  |  March 20, 2009 at 2:40 pm

    Very nice guide; Time Machine is currently running the initial backup to my Ubuntu server.

    I have suggestion which greatly simplifies the procedure:
    While Time Machine tries to initialize the disk image at the server the first time, run ‘ls -l /Volumes/Hcomp’ (the mount point of the network share) several times until the disk image filename appears in the list.
    This removes the complexity of getting the MAC address of the (correct) network card.
    The filename create by Time Machine will look lik this: Hcomp_000045128a91.tmp.sparsebundle (notice the “tmp”), so just remove the “tmp.” part, and the filename can be used.

    Reply
  • 37. Damian Black  |  March 20, 2009 at 7:27 pm

    TimeMachine on windows has suddenly stopped working for me…
    I get an error “The backup disk image could not be mounted”. I recreated a sparsebundle and got the same error. I am able to access the sparsebundle as a remote drive, but TimeMachine can no longer mount it.

    Any ideas? Is this an update to OSX that is stopping this? One clue: it takes a long time before it tells me of the error. Same problem trying to enter the time machine for that file.

    Reply
  • 38. Mark  |  April 12, 2009 at 1:21 pm

    Genius!!! Just bought a secondhand older WD MyBook World raid drive and have struggled for days trying to get the sparsebundle created to the point of giving up until I found the commands on this site. Worked perfectly and Time Machine backing up with no problems as I’m typing this!!!

    Thankyou so much.

    Reply
  • [...] TimeMachine die eben eingerichtete Platte zu nutzen, lege ich Jedem das folgende Tutorial ans Herz: Timemachine and Samba, von [...]

    Reply
  • 40. JJ  |  May 11, 2009 at 9:34 am

    Following on what Jeff Dempsey added, while making first unsuccessfull attempt at backup, keep console open focused on ‘All messages’ and filter it by ’sparsebundle’. You should get message saying something like:

    Creating disk image /Volumes/yourvolume/computer name_macaddress.sparsebundle

    Point being is, on different application versions, time machine will try to make sparsebundle of different name, and what you need is file named EXACTLY like time machine tries to name it.

    Thanks for the awesome tutorial :)

    Reply
  • 41. Peperoca  |  May 20, 2009 at 12:36 am

    What happens when the image fills up?

    It worked perfectly (over wifi) until i reached the maximum space, now i can’t access the backup nor continue to back up.

    Thanks

    Reply
  • 43. Mathieu Guastella  |  May 25, 2009 at 2:24 pm

    Great job !! I’m using a Mac still 1 day and having added RAM, upgraded to leopard and configured time machine… Really good hardware.. and software too.

    But NEVER-SINCE so good and concrete community of users.. That doesn’t exist on PC..

    Thanks !!

    Mat

    Reply
  • 44. Pascal  |  July 10, 2009 at 9:06 pm

    Great!!! Just took my new server in use, and this was the last thing that i couldn’t get running.. Now it works great!!!!

    Reply
  • 45. Bart  |  July 18, 2009 at 1:54 am

    Thanks for the tip. I’ll second the suggestion to use Console to view the correct name for the sparse bundle. I forgot that my computer name was mixed-case, but the logs in Console revealed the correct name.

    Some have asked about restoring from a backup done this way. I just figured that out.

    I’m not sure if it’s possible to do the restore during the system install, but it can be done after through Applications->Utilities->Migration Assistant.

    You don’t have to have Time Machine configured to use the Samba share, but you do have to mount the Samba share in Finder, as described in this article. Then double-click the sparse bundle. This will verify and mount it. Now run Migration Assistant, and select “From a Time Machine backup or other disk.” Your backup will appear there, and you can restore from it.

    Reply
  • 46. David Jameson  |  August 4, 2009 at 2:32 pm

    Perhaps this is a silly question, but if I have mounted the share, why can’t Time Machine create the bundle itself on the share? Why does this have to be done manually?

    Reply
  • 47. Buee  |  August 5, 2009 at 11:25 pm

    Absolute genius! Been trying to get this going for weeks. Thanks.

    One concern I have is, does it go by the MAC address in the sparse bundle? I ask because I would like to do the initial backup via gigabit ethernet, but that will obviously have a different MAC address.

    Reply
  • 48. Marty  |  August 13, 2009 at 10:24 am

    Works great, thanks a lot!

    Regarding the worries about full restore, the screenshots at http://blog.duncandavidson.com/2008/01/restoring-from-time-machine.html suggest that it should be possible to connect to a remote disk (the samba share) at the time you boot from the OS X DVD. Haven’t tried it myself though. Worst case scenario would be a clean install and then restoring your personal files from there, I guess.

    Reply
  • 49. Simon C  |  August 23, 2009 at 12:21 pm

    Awesome!

    This works really well. I am now using time machine to backup my MBP wirelessly to a USB drive attached to a windows XP machine on my wired network.
    It took a bit of fiddling with my firewall settings, and as other people noted above the drive name needs to exactly the same as the name of the Mac Book but now all works a treat. Saves me having to buy an Airport Extreme just to share a USB external HDD across the network! Only question I have is about the implication in backing up to a drive that is formatted NTFS and not for Mac OSX?

    Excellent work!

    Simon

    Reply
  • 50. Matt  |  August 29, 2009 at 1:27 am

    Wow. This works like a charm with my Windows fileshares + Mac laptops (looks like I’m not alone) and is exactly the kind of support I like to see coming out of the Mac community. Awesome job!!

    Mac lovers appreciate macs for their simplicity. However, still gotta be able to tinker every so often to make it truly powerful.

    Kudos.

    Matt

    Reply
  • 51. David Jameson  |  August 30, 2009 at 1:01 am

    I have now done this for 4 different machines. To make it more convenient, I created a .bashrc function as follows

    function maketimemachinesparsebundle()
    {
    size=$1g
    macaddress=`ifconfig en0 | grep ether | sed s/://g | sed s/ether\ // | tr -d [:space:]`
    hostname=`echo $HOSTNAME | sed s/.local//`
    volname=”Backup of $hostname”
    diskname=”$hostname”_”$macaddress”.sparsebundle

    sudo hdiutil create -size $size -type SPARSEBUNDLE -nospotlight -volname “$volname” -fs “Case-sensitive Journaled HFS+” -imagekey sparse-band-size=262144 -verbose $diskname

    }

    So now all you have to write

    maketimemachinesparsebundle 200

    to create a 200Gb sparse bundle ready for use

    Reply
  • 52. David Jameson  |  August 30, 2009 at 1:04 am

    By the way, I found a very useful shareware program called “Back in time” that’s rather useful if you’re administering multiple backups…it will open any of the sparse bundles and let you get at whatever you need.

    http://www.tri-edre.fr/english/backintime.html

    Reply
  • 53. Jeremy  |  September 2, 2009 at 1:11 pm

    David Jameson, your function worked perfectly. I just made a simple shell script called ‘tmvol.sh’, removed the function wrapper, and passed the size as first param like ‘./tmvol.sh 250′. Worked great! Thanks!

    Reply
  • 54. David Jameson  |  September 2, 2009 at 2:40 pm

    Glad it worked for you — I guess I should have done it as a shell-script in the first place, but I just happened to have .bashrc open at the time so that was convenient.

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

 

April 2008
M T W T F S S
     
 123456
78910111213
14151617181920
21222324252627
282930