Bill Morefield My thoughts, discoveries, and occasional rambiings.

June 19, 2013

Time Machine Backups to a Windows Server in Mountain Lion

Filed under: apple,osx — Tags: , , — Bill Morefield @ 9:54 am

Since I moved to a MacBook as my laptop a couple of years ago, I’ve had one continuing problem with backups.  In my mixed Windows/mac environment I’ve used an HP MediaSmart Windows Home Server as my file storage solution for both systems and mostly that’s worked well.

At first Time Machine backups from Snow Leopard to this server worked fine as the HP server included software that allowed it to function as a native Time Machine destination.  That stopped working with the changes that Apple made to Time Machine in Lion.  HP being HP, they never updated their tools to work with Lion.  Once I upgraded to Lion I found no good alternative so I changed to the use of an external USB drive to store my backups.  I never really liked this solution since it required me to remember to plug in the drive on a regular basis. It also ran slowly at times and I didn’t like that it put part of my backups in a different place than the rest of them.

I finally found a solution that is not perfect, but is as close I’ve gotten.  Recently I had to redo this when the disk that held the backups had some issues because of a bad hard drive on my server and thought it worth documenting. It’s been more than a year since I set this up so I can’t provide the links to the blog post that got me thinking this direction so unfortunately I can’t credit them.  Still this is how to create a pretty good TimeMachine backup destination for a Lion or Mountain Lion Mac to a Windows Server.  In fact it should work with any storage that is network accessible and doesn’t natively support updated Apple’s AFP protocol.

This works by creating an Apple disk image on a server share.  This is the same concept used by VMWare and Parallels to create disk images for virtual machines.  Here though we’ll set up a disk image that we can later mount from our Apple that works as a destination for our backups.

  1. Start the Apple Disk Utility.  Easiest way is to bring up Spotlight and start typing in Disk Utility.
  2. Make sure that you do not have a drive selected and click New Image…
  3. I had problems creating the disk image directly on the external storage. When I tried creating the image on the remote storage it would never mount correctly. Instead I created the disk image on a local drive and then moved it to the server share.  This would normally be a problem since we want our disk image to be large enough for our backups and therefore want it at least as large as our hard disk.  To work around this, and save storage space until it’s needed, we’ll create a sparse bundle disk image.  This type of disk only allocates space when it’s needed.  It will run slower than a preallocated image, but I’ve found the difference isn’t noticeable.
  4. Now give the image a name.  I used MacBook-Backup for mine.  You will need this name later, so make sure it’s easy to type.
  5. Next skip ahead in the dialog and change the Image Format to sparse bundle disk image. This lets us create a disk image that will grow over time so we do not need to allocate all the space at once. It also let’s me allocate a 1 TB backup disk and still create it on the 500 GB SSD in my MacBook.
  6. You’ll want to size the image based on how much you have to backup and how long you want to be able to go back to retrieve data. Since I’d been using a 1 TB USB drive I decided to create the image the same size and found that’s worked well for me. Under the Size dropdown select Custom… to enter any size that you’d like.
  7. For format the default Mac OS Extended (Journaled) works fine so leave it.
  8. Encryption is optional.  For an actual portable disk like the USB drive I’d consider encryption a necessity.  With a network stored file the question is how much you trust the other people who may have access to your server.  If you want to be safe, 128 bit encryption works well.  I’m using it on my backup.
  9. You can create the image anywhere on your computer.  I gave it the name MacBook-Backup.sparsebundle to make it clear what it was.  Again since it’s a sparse bundle it will only initially use a small amount of disk space regardless of the size of the disk image.
  10. Once Disk Utility finishes creating the image, unmount it, and move it to your remote storage.  In my case I created a new share on my server and gave my account read/write access to that share.  I then moved the file into the share.

With the image file now on my storage, I next had to tell my Mac where this file was and to use it as the Time  Machine destination.  If you try to do this through the GUI as normal you’ll see that only external drives and AFP supporting devices (generally either a Time Capsule, Airport Base Station, or NAS with the necessary support) show.  Instead we need to use the tmutil command to tell Lion where this image file is

To do this I found the easiest approach to first mount the image to your computer.  To do this connect to your external storage where you placed the file.  In my case this was a cifs share and I mounted it using the Go -> Connect to Server… option in Finder.  Once I did this it and I entered my login credentials I could see the disk image.  To mount the image double click on it.  If you created an encrypted image you will be asked for the password.  You can choose to store the password in your keychain so you will not need to enter it each time.  Once the image is mounted, you will see it in Finder under Devices much as you would an external drive.  The name will be the image name you entered in step 4 above.

If you want to move any existing Time Machine backup you can do so.  Apple provides instructions to do this at https://support.apple.com/kb/HT5096.  In this case the disk image functions just as an external drive would.  It takes time, but allows you to keep your existing backup data.

Next start Terminal.  At the prompt enter the following command to tell Apple where our Time Machine destination will reside:

sudo tmutil setdestination /Volumes/Mounted Image

Change Mounted Image to the name of the device in Finder after you mounted it.  In my case since I gave it the name MacBook Backup in step 4, my command is:

sudo tmutil setdestination /Volumes/MacBook-Backup

Try running a backup now by going to the TimeMachine icon and select Backup Now.  Depending on how much data you have on your Mac and the speed of your network it might take a while.  If you have a lot to backup the first time doing so with a network cable instead of wireless can speed it up significantly.  If you have an existing backup it may be faster to transfer it to the new image which will allow the backup to pick up from there.

After a few days this is working well.  I’m now getting regular backups instead of only when I remember to plug in the USB drive and have the time to let the backup run.  I’ve found the backups over my wireless to be much faster than over the USB 2 in my MacBook.  I also feel more confident my backup is up to date and will cover if something happens to my laptop or hard drive.

It’s not perfect though.  Since this is for all purposes an external drive it functions much as connecting a physical drive and not as a network destination.  To kick off the backup, you must manually attach to the server and mount the drive. I’ve also found that when networks other than my home, I get errors about not being able to connect to the storage when the Mac attempts to start the backup. I’ve generally just ignored these since there seems to be no problem other than the error message.

February 3, 2012

Adding Recovery Partition to Lion Install

Filed under: apple,osx — Tags: , , , — Bill Morefield @ 8:00 am

As I mentioned in an earlier Mac post, I upgraded my MacBook Pro with a larger 500 GB hard drive.  I made the move by cloning my existing hard drive to the new hard drive which I’d attached by USB.  This worked perfectly – until I went to encrypt the new drive.  It turns out my clone tool didn’t copy the hidden recovery partition.

I’m a big believer that any notebook or portable computer should be encrypted.  My previous PC was encrypted using Truecrypt which worked wonderfully.  When I moved to the Mac, I was happy to see Lion added support for real encryption.  I did that soon after upgrading to Lion with no problems.

I like encryption because I consider my data the most valuable things I have.  I don’t want to lose my hardware, but I really don’t want someone else able to flip through my data.  I try to keep the really important stuff off my laptop, but you never know what might slip onto it.  I like the thought that if my notebook is lost or stolen I can simply get my data back from the last backup while the thief can’t find anything.

When I went to encrypt the new hard drive, Mac OS informed me it couldn’t because the recovery partition was missing.  Some research led me to backing up my data to an external hard drive, and then doing an install and restore.  I did this, but apparently missed a step and still no recovery partition after almost a day of backup/install/restore.

I had some other tasks to work, on so I put this one off for a while.  I finally came back to this week.  My research led me to a blog post by Dmitry Dulepov that outlined a fairly straightforward process.  You install Lion to a USB drive, repartition your hard drive to create space for the recovery partition, and then copy the recovery partition from the USB drive to the hard drive.  I had a USB thumb drive that worked fine.  When I finished all went well until I looked for the recovery partition on the USB drive and didn’t see one.  Apparently this recovery partition is harder to create that I’d thought.

More reading showed me a couple more options.  First came trying to re-run the installer.  While that might have worked, I was a little wary given my track record with the installer not creating this partition.  So I did some more research which led me to this blog post on removing and rebuilding the recovery partition that referenced this entry.  I didn’t need to remove, but I did need to rebuild.  I skipped the removal of the partition in that first entry and followed the steps to rebuild it.  It worked.  I rebooted to find the recovery partition there and was immediately able to encrypt the drive.

February 1, 2012

Enable/Disable Root in Mac OSX

Filed under: apple — Tags: , — Bill Morefield @ 6:15 pm

Just to make it easier to find later. How to enable/disable root user in OS X Lion.

Powered by WordPress