NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

AndyWheatcroft's avatar
May 10, 2019

Restoring a Time Machine Sparse Bundle to a new NAS

This post is to document the steps that I took in restoring Time Machine sparse bundles to a new NAS and getting the Macs to recognize the Time Machine backup as theirs.  I could not find a complete set of instructions so I thought that the Mac users out there that use a NAS with OS6 might appreciate not having to do all the research that I did.  The instructions are quite verbose since I want anyone to easily follow the procedure.

 

Background – why did I need to do this?

I own a ReadyNAS Pro6 (RNP) that was happily running 4.2.31 with 5 x 3TB disks in a RAID 6 (dual redundancy) configuration.  Until one drive died and managed to corrupt a number of system files/settings.  I tried desperately to bring the system back to some level of normalcy but even with the help of a couple of super users in the forum, I could not get the system out of “degraded” mode.  So, I decide it was time to take the plunge and go to OS6. This will completely re-format the drives and force you to restore any and all data from backups.  Fortunately for me, I have multiple backups and I knew I was in good shape.  My main backup is on a Seagate 8TB external drive.  It contains everything.

 

I am not going into the details of upgrading a RNP from 4.2 to OS6 – that is well documented but I should point out that it is wise to do so with a single unformatted disk installed in the unit.  I had hours of hair pulling due to trying to do the upgrade with all my old drives in place.  Once I removed them, it was plain sailing.

 

So now I have a RNP with OS6 (6.9.5 in my case) with all my old drives back in and sadly, it took 18 hours to build out the new RAID 6 volume.  With OS6, you get to choose the name of the volume which I called “MAIN”.  Don’t ask me why – it just seemed logical at the time.

 

Restoring user files was easy – no need to go into that.  But now I really wanted to get my users Time Machine backups restored.  If you don’t care about the old data in these backups, then just configure new Time Machine shares and perform complete backups from the Macs.  But that’s not what my users wanted.  I am going to walk through the steps I took for one Mac and it’s Time Machine backup.  The first thing you need to understand is that the TM backups on a NAS are stored in what is called a sparse bundle.  You don’t need to know anything about it except that it doesn’t look like any normal type of backup or file system.

 

I already told you that the volume on my RNP is called “MAIN”.

The Mac that had a TM backup used an account named “tmandymbp” for storing its backups.  This is important to know since you need to be able to find the data on your backup device.

Log onto the Mac (using an account that has admin rights) and open TM Preferences.  Make sure backups are not enabled.  Click on “Select Disk” and remove your old backup disk.

In your preferred browser, log in to the admin page of your the NAS.  In my case, the IP is 172.16.2.35.

Attach your back device up to one of the USB ports.  If you don’t have a backup, I would stop reading at this point!

Now when I look at “Shares”, I see “MAIN” and “External” and under external is “USB_HDD_1”.

Since my backups were from an old 4.2.31 system, my TM backups are under “HomeShares”.

Drilling down, I can see a folder named “tmandymbp”.  Yeah – this is where my TM back up resides.

Under “System” -> “Settings”, make sure SSH is enabled.  If not, enable it.  (Ignore all the warnings – you want your data back don’t you?)

Under “Accounts”, create new user (“tmandymbp” in my case).  I added this new account to group “admin” – not sure if it was necessary but I didn’t want to run into any issues due to lack of permissions.

Under “Backups”, click on “Time Machine” and add a new “Private Time Machine”.  You will be presented with a list of accounts.  Enter the capacity, (750GB in my case), and then click on the account name (tmandymbp) and then click on “Add”. Now you should see an entry under Private Time Machines with your account and showing 0 GB used.  It is recommended that you use SMB for TM backups since AFP is being phased out by Apple.  I had one really old Mac that we still use that doesn’t support SMB, so my Time Machine is set to AFP.

 

Now the fun begins.

Open a Terminal window and login into your NAS.  I use my IP:

ssh -l root 172.16.2.35

If you have never used SSH to your NAS, you should get in but since mine was a rebuilt using the same IP and device name, I get refused with the error message:

REMOTE HOST INDENTIFICATION HAS CHANGED.

Eek – but not to worry, navigate to “/Users/{user_name_of_account_you_are_using}/.ssh”.

There you should find the file “known_hosts”.  Edit the file:

vi known_hosts

Put the cursor on the line that has the name or IP of your NAS and enter “dd” which will delete one line. Then save the file - enter “:wq” and press enter.

Now try logging in again.  This time you should be requested to accept a new authentication.  Type “yes” and press enter.

Then you will then be prompted for the admin password for the NAS – enter it and hit enter.

You should get a welcome message and show that you are logged in as “root”.

Now it is useful to find out how big your sparse bundle back up is.

cd /media/USB_HDD_1/HomeShares

You should find your old TM backup directory there – mine is named “tmandymbp”.

CD into this directory and enter:

du -sh .

This tells you how big the backup is.  In my case, it returned “502G”.  WARNING – if you did not allocate enough space to hold this when you configure the Private Time Machine, go back and increase the size.

I knew my back up was huge, hence the reason I allocated 750 GB.

When we restore this data, it is useful to know how far the copying has completed.

There should be a directory with a name the ends “.sparsebundle”.  In my case the directory was named “MacBook Pro.sparsebundle”.  NOTE the blank in the directory name.  These can and will cause problems if not handled correctly.  CD into your sparse bundle directory.  In there you will find a directory named “bands”.  CD into it.

So now, pwd returns:

/media/USB_HDD_1/HomeShares/tmandymbp/MacBook Pro.sparsebundle/bands

Enter “ls -l | wc -l”.

This tells you how many files are in “bands” – 64121 in my case.  Each file is 8K in size.

Go back up two directories – “cd ../..” – you should be in the directory of the account owner.

You have verified the location of your back up, now let’s verify the target.

Open a second terminal window and log in - “ssh -l root {your_ip}”.

Time machine data is stored in a hidden directory named “.timemachine” right under the primary volume – “MAIN” in my case.

cd /MAIN/.timemachine

You should see an empty directory with the name of the account that you specified as a Private Time Machine account.  In my case it is “/MAIN/.timemachine/tmandymbp”.

This is where we need to copy the sparse bundle to.

Switch back to the first Terminal window.

You should still be in “/media/USB_HDD_1/HomeShares/{account-name}”.

Now we copy everything from this directory:

cp -r * /MAIN/.timemachine/tmandymbp

Depending on a lot of factors, but mainly size, this can take hours.

But it is nice to be able to monitor the progress, so switch to terminal window #2.

Enter “ls” and you should see the directory with the sparse bundle name.

CD into it, verify that “bands” has been created and cd into “bands”.

Now you can monitor the progress of the copy using “ls -l | wc -l”.

For me, I could see that it was copying about 15,000 files an hour, so 64,121 files took over 4 hours.

If your sparse bundle is large like mine, time to take a break.

 

When the “cp” command completes in terminal window #1, verify that you have the correct number of files in “bands” in terminal window #2.

“ls -l | wc -l” returns 64121, so I know the copy was good.  Terminal window #1 can be closed.

In terminal window #2, you should still be it the “bands” directory.

Go back up three directories – “cd ../../..” – you should be in the “.timemachine” directory.

We must now fix a couple of things with the files and directories.

First, everything is still owned by “root”, so we change ownership:

chown -R {TM_Account}:admin {TM_Account}

For me – “chown -R tmandymbp:admin tmandybmp” – NOTE the use of upper case “R”.

Even with a large number of files, this only takes a few seconds.

Now we need to change a couple of file settings.

CD into your TM backup – “cd tmandymbp”.  “ls -l” should show your change of ownership.

We need to change the permissions of the sparse bundle.

Now this is where blanks will get you if don’t escape them.

chmod 700 MacBook\ Pro.sparsebundle

chmod g+s MacBook\ Pro.sparsebundle

CD into your sparse bundle directory:

cd MacBook\ Pro.sparsebundle

and make the same permssions change to the "bands" directory.

chmod 700 bands

chmod g+s bands

 

The final part – open Finder.

Connect to your NAS specifying the volume name that contains the timemachine backups. (Go -> Connect to Server)

For me – “smb://172.16.2.35/MAIN”

Use the credentials of the timemachine account.

Alas, it doesn’t show you what you need since we must see the hidden folders.

Click “CMD+SHIFT+.”

You should now see “.timemachine” (in light grey).

Drill down two levels to display the contents of your restored data.

In my case, the navigation bar shows “MAIN > .timemachine > tmandymbp”.

Go back to terminal window #2.

You are still logged into your NAS, so enter “exit”.  You are now back on your Mac but still in an active terminal window.

Type the following, BUT DO NOT HIT ENTER:

sudo tmutil inheritbackup

Making sure there is ONE space at the end.

Go back to finder, click and hold the file name of your sparse bundle and drag it into the terminal window.  Make sure there is a space between “inheritbackup” and the full path name of the sparse bundle. Press enter and hopefully you will see:

Attaching disk image...

** /dev/rdisk3s2 (NO WRITE)

   Executing fsck_hfs (version hfs-407.50.6).

QUICKCHECK ONLY; FILESYSTEM CLEAN

Claiming disk image for machine...

Ejecting disk image...

 

That should do it.

 

Now open Time Machine and select the backup disk.

You will need to authenticate using the TM Account name and password.

What you will see is the space left – 212 GB of 750 GB in my case.

BUT the dates of the oldest and last backups are not displayed.

Don’t worry, after you make your next incremental backup, they will appear.

 

Points to remember:

In my notes, where you see “MAIN”, substitute for your primary volume name.

In my notes, where I used my IP, substitute the IP of your NAS.

In my notes, where I used “tmandymbp”, substitute the name of the account that holds your time machine backups and is the same name that will be used in OS6.  Some of my reference use “{TM_Account}”.

 

Good luck! 

 

 

 

 

1 Reply

Replies have been turned off for this discussion
  • WOW, I'm impressed.  I had a similar situation with my pro 4 and a time machine sparse bundle. Unlike you I ended up in frustration, and just started a new backup.  There was good that came from the experiance.  Giving it some thought, I decided that a backup system that was problematic wasn't a good solution for me.  I switched over to using Chronosync for a backup.

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More