Fix Time Machine Sparsebundle NAS Based Backup Errors

Time Machine

This is a modification of an original post for use when you have a corrupt sparsebundle backup on a NAS (as opposed to an external drive attached to a router) and it needs to be repaired. The NAS is likely a hardware product from the likes of Netgear, Synology, Buffalo or QNap – or for those of us with a home-grown backup server running FreeNAS.

The error you may see is “Time Machine completed a verification of your backups. To improve reliability, Time Machine must create a new backup for you.” This can be fixed by following the below.

From your Mac, connect to the network share that houses the sparsebundle.

At the top level of the drive are the various sparsebundles that make up your individual computer backups.

Do not double click on these sparsebundles or try to repair with Disk Utility.

Open Terminal and then switch to root by typing

sudo su -

and then enter your password.

The verication that has already run has marked your sparsebundle as bad, so first we need to make it look normal.

From the command line

chflags -R nouchg /Volumes/{name of your network share}/{name of}.sparsebundle

This may take a little while.

Now type

hdiutil attach -nomount -noverify -noautofsck /Volumes/{name of your network share/{name of}.sparsebundle

You will then see something like

/dev/diskx Apple_partition_scheme
/dev/diskxs1 Apple_partition_map
/dev/diskxs2 Apple_HFSX

Where x is the disk id for the external disk. You are interested in the one labeled Apple_HFSX or Apple_HFS. It might be 2, 3, 4 or higher.

At this point, I have found that the filesystem check is already happening. You can check for activity by tail’ing the fsck_hfs.log

tail -f /var/log/fsck_hfs.log

If fsck is going then in my experience it will be able to repair the sparsebundle. Go away for a few hours and let it chug away.

When it is done, you will either see

‘The Volume was repaired successfully’

or

‘The Volume could not be repaired’

If the latter you can run disk repair again:

fsck_hfs -drfy /dev/diskxs2

(Optionally if you have the available RAM, you can set a RAM cache in the command above to help speed up this command like so:

fsck_hfs -drfy -c 750 /dev/diskxs2

This will use 750MB of RAM – feel free to change this amount to best fit your system (amount of RAM vs size of your Time Machine Sparsebundle). If you are unsure about this, use the first command.

Make sure to replace x with whatever number your disk is from the output above.

The letters “drfy” tell the filecheck utility different things. d for ‘Show Debug’ – r for ‘Rebuild Catalog Tree’ – f for ‘Force’ and y for assume ‘yes’ to any prompts.

Now go do something for an hour or two. Come back and

tail -f /var/log/fsck_hfs.log

If all went well, the last output you will see is

‘The Volume was repaired successfully’

Now you need to type
hdiutil detach /dev/diskxs2

You can redo the above for any other Time Machine sparse bundles you have permission to modify while you have the network share attached to your computer.

Final step.

When complete, you need to edit an plist file within the sparsebundle that records the state of the backup. On the top level of the sparsebundle find a file called com.apple.TimeMachine.MachineID.plist. Edit it and remove these two nodes

<key>RecoveryBackupDeclinedDate</key>
<date>{whatever-the-date}</date>

Finally you want to change

<key>VerificationState</key>
<integer>2</integer>

to
<key>VerificationState</key>
<integer>0</integer>

Now you can eject the network share and have Time Machine give it another go. After the (long) verification step, backups should proceed once again.

Notes:

Ideally this should be done over a gigabit wired network connection. Do not attempt using Wi-Fi. You also want to make sure your machine does not go to sleep during the above operation.

[Update: 1.1.2013]

I appreciate all the warm feedback from people all over the world who have been helped by this post. This site helps to fund my hobbies, so if this post has helped you please consider a USD $1.99 donation to my hobby fund.

[paypal-donation]

[Update: 12.23.2012]

If after running the initial

fsck_hfs -drfy /dev/diskxs2

command you get a message in the fsck_hfs.log along the lines of

RebuildBTree – record x in node y is not recoverable.

then try

fsck_hfs -p /dev/diskxs2

followed by

fsck_hfs -drfy /dev/diskxs2

And see if that works.  It did for me today.

330 thoughts on “Fix Time Machine Sparsebundle NAS Based Backup Errors

  1. Many thanks for your clear instructions on this. I’m fed up getting the “backup cannot be used message” and this solved the latest episode. There is one amendment to your instructions which I feel is critical to success. The plist is not at the root of the actual sparse bundle, rather it is viewable when clicking on the sparse bundle and electing to see the package contents. Once I sussed that out the rest was plain sailing.

    For interest sake. My problems with failing Time Machine backups seem to occur when I’ve taken my backup source (a MacBook Pro) out to customers, switched it to WiFi, and then returned to the office and forgotten to switch back to wired Ethernet. As long as I remember to make the switch before TimeMachine kicks in my backups work fine, the moment I let TimeMachine kick in whilst the machine is connected via WiFi I start getting problems.

  2. Awesome. Thanks! So glad I found this page after trawling through various forums. Worked for me first time. btw I’m running Mountain Lion 10.8.4 on a Mac Mini and Synology DS213+ as my NAS. Backing up over gigabit ethernet, occasionally wifi if I need ethernet for something else.

    1. Sad to say no it didn’t work for me in fact 🙁 I followed through the instructions without issue and TM started backing up again to old TM share on Synology. Then I posted my above comment. I fired up time machine to see when the oldest back up was, nothing showing before today. Previous months backups just don’t show/or don’t exist anymore? :-((

  3. Thank you soooooo much. I have used this guide many times and it has saves my a$$ every time. Next step would be to write a script so this this process is automated step by step. That would be awesome! Keep up the good work and thanks again.

  4. It worked!! Thanks!
    The only thing I couldn`t use was the “tail”-line. It just didn´t work. But I just proceeded with the next line and now I get a back up that´s based on an image that´s already one month old. Great!

  5. hi,

    after i type in:

    hdiutil attach -nomount -noverify -noautofsck /Volumes/Time\ Machine/gbook.sparsebundle

    i get:

    hdiutil: attach failed – Die Ressource ist zeitweilig nicht verfügbar

    what went wrong?

    thanks for any input,
    jens

    1. Hi jensenbln,

      I’m getting the same error. Did you get it fixed already? thanks dude

  6. OK; I am back – it was wise I donated, because the apostrophy thing only seemed to fix the problem which resurfaced today.

    I am now running the procedure – but the chflags command seems to take *a lot* (like over 30 mins so far). Normal?

  7. Hello again, i just noticed i made a mistake on my last post, the latest message i get from TM is: TIME MACHINE COULDN’T COMPLETE THE BACKUP TO “FREEBOX-SERVER” Time Machine can’t use the disk image because it can’t be written to.

    I’d really appreciate any help!

  8. Hello! thanks for the post but sadly i’m still experiencing issues. Whilst at the beginning time machine would, out of the blue, show up a message saying: “Time Machine completed a verification of your backups. To improve reliability, Time Machine must create a new backup for you.” now, after i have followed all the above steps (it actually got repaired at the first try without having to do any of the extra stuff i have this message now “Time Machine completed a verification of your backups. To improve reliability, Time Machine must create a new backup for you.”

    Any ideas on what could i do to fix this?
    Thank you so much in advance!

  9. Thanks for the solution, currently working through the steps to see if it will work for me…

    one question though…. what causes this to happen ? why is the sparse bundle now corrupted ?

    im using FreeNAS and this happens regularly… i would rather find the cause and fix that than keep having to do this all the time…

    whenever i reboot the NAS or a Scrub happens, the sparse becomes corrupted (as it seams) but how ? what changed to make OSX think its corrupted ?

    Dan

  10. Thanks for writing this, it’s super helpful and fixed the problem for me. However, after a few days it errors out again I have to repeat this process. Any idea how to make the fix more permanent?

  11. This is good! I donated, even though eventually my problem may have been a simple case of a stupid name which caused TM to keep losing the sparsebundle. I have now removed the offending character (apostrophy) from the machine name and redone the back up. So far, so good, but we’ll see in a few days

  12. OK, this is where I got stuck. Can anyone help? I am glad to donate to get this fixed. 🙂

    disk0-in-yo-howse:~ root# fsck_hfs -drfy -c 1000 /dev/disk2s2
    journal_replay(/dev/disk2s2) returned 5
    ** /dev/rdisk2s2
    Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
    Executing fsck_hfs (version diskdev_cmds-557~393).
    could not get volume block 2, err 5
    could not get alternate volume header at 4194099198, err 5
    volumeType is 0
    0000: 0020 0708 0100 0000 0000 0000 0000 0000 |…………….|
    0010: 0000 0000 0000 0000 0000 0000 0000 0000 |…………….|
    . . .
    01f0: 0000 0000 0000 0000 0000 0000 0000 0000 |…………….|
    unknown volume type
    primary MDB is at block 0 0x00
    alternate MDB is at block 0 0x00
    primary VHB is at block 0 0x00
    alternate VHB is at block 0 0x00
    sector size = 512 0x200
    VolumeObject flags = 0x01
    total sectors for volume = 4194099200 0xf9fce000
    total sectors for embedded volume = 0 0x00
    CheckForClean – unknown volume type
    CheckHFS returned 6, fsmodified = 0

  13. Hmmm… I am getting a different error. I really am terrified to lose my backup yet again to a random rebuild. Is there anyway someone could help. I am glad to donate. Here is how far I have gotten:

    disk0-in-yo-howse:~ root# fsck_hfs -drfy -c 1000 /dev/disk2s2
    journal_replay(/dev/disk2s2) returned 5
    ** /dev/rdisk2s2
    Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
    Executing fsck_hfs (version diskdev_cmds-557~393).
    could not get volume block 2, err 5
    could not get alternate volume header at 4194099198, err 5
    volumeType is 0
    0000: 0020 0708 0100 0000 0000 0000 0000 0000 |…………….|
    0010: 0000 0000 0000 0000 0000 0000 0000 0000 |…………….|
    . . .
    01f0: 0000 0000 0000 0000 0000 0000 0000 0000 |…………….|
    unknown volume type
    primary MDB is at block 0 0x00
    alternate MDB is at block 0 0x00
    primary VHB is at block 0 0x00
    alternate VHB is at block 0 0x00
    sector size = 512 0x200
    VolumeObject flags = 0x01
    total sectors for volume = 4194099200 0xf9fce000
    total sectors for embedded volume = 0 0x00
    CheckForClean – unknown volume type
    CheckHFS returned 6, fsmodified = 0

  14. Hi Garth,

    Thank you for your solution, it rocks! I used this a month or two ago, and it did the trick. However it just came up again, and I think I know the cause in my situation. maybe this will help others.

    Mac Mini running 10.8.3
    Synology NAS
    Time Machine

    I usually have Mac connected to router via wireless, and NAS is connected to router via ethernet.

    Yesterday, I was downloading a movie, and it was taking a really long time via wireless, so I hooked up Mac via ethernet. When finished, I made sure time machine wasn’t backing up and disconnected ethernet cable. Sure enough, soon after that I got the “Time Machine completed a verification of your backups on “Synology”. To improve reliability, Time Machine must create a new backup for you” error.

    So, it looks like switching Network internet connection has confused time machine backup? Is this plausible, and is there something I can do in addition to your fix to prevent this happening again?

    Thank You!

    1. Happened to me after switching connection too. So you’re probably right.

  15. Amazing – this worked perfectly and I am very grateful for these instructions! Donation is on its way!
    I had been running TM on a Synology DS412 for a few months, for two MB Pro (one with 10.7.5, the other one with 10.8) and one Mac mini server (10.6.8). TM was running well but suddenly I got that dreadful error message this evening. I haven’t done any OS update so I have no idea what could be the cause. TM was working for the other Macs, and the DS didn’t report any problem with the disks. TM reported the error for my MB Pro. So, it was a great relief to see it work – but I can imagine that not all users are comfortable with this kind of fix…….

  16. Hey Garth,

    Thank you for your explanation. I almost took the plunge and tried your solution for the problem ‘{ }.sparsebundle on Time Capsule temporarily not available’. As a last resort before doing so, I restarted my Time Capsule.. after which the sparsebundle was recognized and available again and showing in the Migration Assistant of my new Mac (previous one was stolen last weekend). Apart from a couple of hours worrying about my data, nothing was lost.. Just sharing this to mention that the solution sometimes is closer than one might think.

    Cheers,
    Ramon

  17. Had a few issues- fsck showed no errors on the disk, and I couldn’t find the RecoveryBackupDeclinedDate .plist in the sparsebundle. I’m using an encrypted backup, so not sure if that makes a difference.

    Any ideas?

    1. Update – I fixed my problems – turns out I wasn’t running the fsck check/repair manually (it appears to make a difference) – and I also couldn’t initially find the MachineID .plist file – finally found it. For my volume, I needed the -p attempt, but it appeared to work after the second run. So, it’s now attempting a backup again! 😀 Yup- successfully backing up.

      I agree with the others, I think we might be able to make an applescript application out of these instructions. If I get enough motivation (say another TM error), I’ll try to make one and let everyone know. 🙂

      Thanks for saving my backup! This was 1 day into the backup process on my Synology NAS- no idea why it failed, but glad to hear it’s not just the synology that has problems – others even with the Time Capsule are experiencing this.

      I may end up back with rsync, to be honest. I loved it when I had an exact duplicate disk that was bootable with rsync.

      Thanks again!
      -Allen

  18. Thanks Garth!

    I followed this procedure and it saved my Time Machine backups!

    It took me a while to figure out the location of the .plist file, I had no idea I needed to right-click and choose ‘Show package contents’, couldn’t find the file before when I double-clicked the .sparsebundle file.

    Thumbs up!

  19. Hello Garth Gillespie,

    I promise to domate if this starts working again!

    I went through a lot to get to this point – only to get the ‘must make new backup.

    Here’s what is happening. I beliwve theres a permissions error. I am not sure how to change the permissions.

    localhost:~ root# chflags -R nouchg /Volumes/ReadyNAS/Macintosh.sparsebundle
    localhost:~ root# hdiutil attach -nomount -noverify -noautofsck /Volumes/ReadyNAS/Macintosh.sparsebundle
    /dev/disk2 Apple_partition_scheme
    /dev/disk2s1 Apple_partition_map
    /dev/disk2s2 Apple_HFSX
    localhost:~ root# fsck_hfs -drfy -c 1000 /dev/disk2s2
    Unable to open block device /dev/disk2s2: Permission deniedjournal_replay(/dev/disk2s2) returned 13
    ** /dev/rdisk2s2 (NO WRITE)
    Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
    Executing fsck_hfs (version diskdev_cmds-557.3~1).
    Journal is empty
    ** Checking Journaled HFS Plus volume.
    ** Detected a case-sensitive volume.
    The volume name is Time Machine Backups
    ** Checking extents overflow file.
    ** Checking catalog file.
    ** The volume Time Machine Backups was found corrupt and needs to be repaired.
    volume type is pure HFS+
    primary MDB is at block 0 0x00
    alternate MDB is at block 0 0x00
    primary VHB is at block 2 0x02
    alternate VHB is at block 838860734 0x31ffffbe
    sector size = 512 0x200
    VolumeObject flags = 0x07
    total sectors for volume = 838860736 0x31ffffc0
    total sectors for embedded volume = 0 0x00
    CheckHFS returned 7, fsmodified = 0
    localhost:~ root#

    any ideas?

    1. @Peter Davies

      I’m guessing that you are worldranger in the post on the apple discussions page?

      Did I read your posts correctly that after your reinstall of OS X you are using a different username than you used when these backups were made?

      This is probably the cause of the ‘permission denied’ error.

      It is possible to change the permissions in the sparsebundle but in its current state, that is not advised.

      I would try

      1 – Disconnect the share (or just reboot)
      2 – Create a new user with the same username you used prior to reinstall
      3 – login as this new (old) user.
      4 – try the repair steps again.

      I also see you are trying to have OSX associate your existing backup with your reinstalled OS. I think part of the decision tree is the username.

      1. Hi –
        I have exactly the same problem but I have not changed the user nor updated the OS.
        The script worked perfectly before. Could this relate to a recent OS bugfix release?

        Thanks for any hints

        Peter

  20. A hint for all those who do not get past the first step:
    The path to the sparsebundle has to be typed absolutely correct, i.e. in Terminal language. In my case the name of the sparsebundle is Baldur & Halla.sparsebundle In this case the path in Teminal language is:

    /Volumes/Data/Baldur\ \&\ Halla.sparsebundle

    The correct path to the sparsebundle can be extracted with the help of a utility app. In my case I used PathFinder (a Finder repalcement), which offeres the possibility to extract file paths in different programming languages.

    1. BJB

      I agree that the correct path to the sparsebundle in Terminal language is required, but I found it simpler and better to use the key to complete the path once I’d got to a few unique letters of the sparsebundle name. For instance, in your case:

      This command completes the name exactly, if it’s uniquely determined by “Bal”

      I also have an apostrophe in my computer name, and I suspect that is why the Path Finder command “Edit/Copy Path/TERMINAL” did not extract a name for me that worked, whereas simply autocompleting in Terminal using the key did. Thanks for putting me on the right “path” though!

    2. I agree that the correct path to the sparsebundle in Terminal language is required, but I found it simpler and better to use the TAB key to complete the path once I’d got to unique letters of the sparsebundle name. For instance, in your case:

      chflags -R nouchg /Volumes/Data/Bal TAB

      This command completes the sparsebundle name exactly, as long as it’s uniquely determined by “Bal”.

      I have an apostrophe in my own computer name, and I suspect that that is why the Path Finder command “Edit/Copy Path/TERMINAL” did not extract a name for me that worked. However, simply autocompleting in Terminal using the TAB key did.

  21. Hi guys!

    My volume (Synology 212) doesn’t want to repair:


    sh-3.2# fsck_hfs -p -c 750 /dev/rdisk1s2
    Executing fsck_hfs (version diskdev_cmds-557.3~3).
    ** Checking Journaled HFS Plus volume.
    ** Detected a case-sensitive volume.
    The volume name is Time Machine Backups
    ** Checking extents overflow file.
    ** Checking catalog file.
    ** Checking multi-linked files.
    ** Checking catalog hierarchy.
    ** Checking extended attributes file.
    ** Checking multi-linked directories.
    Incorrect number of directory hard links
    ** Checking volume bitmap.
    ** Checking volume information.
    Invalid volume file count
    (It should be 1366023 instead of 1194640)
    Invalid volume directory count
    (It should be 203753 instead of 196891)
    Invalid volume free block count
    (It should be 171144763 instead of 178953736)
    Volume header needs minor repair
    (2, 0)
    ** Repairing volume.
    Invalid first link in hard link chain (id = 754316)
    (It should be 2160180 instead of 2153111)
    Invalid first link in hard link chain (id = 755702)
    (It should be 2160600 instead of 2153535)
    Invalid first link in hard link chain (id = 755705)
    ...
    (It should be 2163625 instead of 2149975)
    Invalid first link in hard link chain (id = 764259)
    (It should be 2163655 instead of 2150006)
    Invalid first link in hard link chain (id = 764323)
    (It should be 2163656 instead of 2150007)
    Invalid first link in hard link chain (id = 764386)
    (It should be 2163657 instead of 2150008)
    Invalid first link in hard link chain (id = 764453)
    (It should be 2163663 instead of 2150014)
    Abort trap: 6

    Do you have any ideas what can help me?
    Appreciate any help.

      1. @Garth Gillespie

        I tried many times and always the same error in same place =(

  22. Are these instructions applicable for a TimeMachine file on a TimeCapsule?

  23. Hi,

    I am new to Terminal and am having problems with it recognising the sparsebundle filename, as it has spaces and an apostrophe in it:

    Mihali Moore’s Computer_2013-04-1-122407.sparsebundle

    I have read that these can be replaced with a \. I have tried this, as well as dragging the file into terminal but to no avail. Any ideas?

    This is what I have got so far:

    Last login: Mon Apr 8 17:55:44 on ttys000
    mihali-moores-computer:~ Mihali$ sudo su –
    Password:
    mihali-moores-computer:~ root# chflags -R nouchg /Volumes/TimeMachineBackup/TimeMachine/Mihali\Moore\s\Computer_2013-04-01-142407.sparsebundle
    chflags: /Volumes/TimeMachineBackup/TimeMachine/MihaliMooresComputer_2013-04-01-142407.sparsebundle: No such file or directory
    mihali-moores-computer:~ root#

    Thanks.

  24. I find myself coming back again and again to refresh my memory on how to do all this. It seems to happen frequently enough to annoy (which is to say more than once) but not so much I can remember the steps.

    I have been working around this by backing up to two different volumes to ensure corruption or whatever the &^&(* keeps happening doesn’t cost me all my data (I have been using Time Machine since the 1st Generation Time Capsules came out but my oldest backup is from December 2012, such has been my struggle).

    But that poses its own problems if you want to see what backups are stored with tmutil listbackups, for example. The volume name is always Time Machine Backups, no matter where it lives. So I used the steps here to give them unique names, based on the volume where they are kept. You still only get a list of backups from one of the repositories, if you use more than one, but at least between that and tmutil destinationinfo you can check up on the process.

  25. Anyone want to translate this howto for ubuntu? So far every command is different and resulting in hours of research. If anyone out there knows the command equivalents off hand, I would be eternally grateful.

  26. Thanks for this.. it just saved my bacon.. again.

    This kind of thing could probably be automated fairly easily in an app. It would allow a lot more people to be helped as it’s so common for this to happen (used to happen to us about once a month even on genuine apple TCs).

  27. Thank you so much for taking the time to put this together, it has saved my time machine backups many times.

    I am finding though, that I have to go through this whole process every couple of days. Do you have any idea why this would be?

    I’m running a new 15″ MBP Retina backing up to a Sygnology diskstation 411 (latest firmware) over Wireless N.

  28. In the first paragraph it says “corrupt sparsebundle backup on a NAS (as opposed to an external drive attached to a router) and it needs to be repaired”,
    I have the opposed to option which is a Seagate GoFlex Home that was attached to my AirPort Extreme base station. Does this have some other type of fix for it? I can mount all sparsbundles except one. I heard about this site from MacGeekGab and they mention the problem usually being caused by a “bands” that wasn’t finished backing up. Well I have that at the end of my backups, it says something like “in process”. So can I try this or no? Thank you

  29. Hi Garth,

    When I run it stops here:

    /dev/rdisk2s2: fsck_hfs run at Mon Mar 18 19:02:09 2013
    /dev/rdisk2s2: ** /dev/rdisk2s2
    /dev/rdisk2s2: Executing fsck_hfs (version diskdev_cmds-557~393).
    ** Checking Journaled HFS Plus volume.
    ** Detected a case-sensitive volume.
    The volume name is Time Machine Backups
    ** Checking extents overflow file.
    ** Checking catalog file.
    ** Checking multi-linked files.
    ** Checking catalog hierarchy.
    ** Checking extended attributes file.
    Incorrect number of extended attributes
    (It should be 1680148 instead of 1680147)
    Incorrect number of Access Control Lists
    (It should be 1680124 instead of 1680123)
    ** Checking multi-linked directories.
    ** Checking volume bitmap.
    ** Checking volume information.
    ** Repairing volume.
    GetCatalogRecord: No matching catalog thread record found
    /dev/rdisk2s2: GetCatalogRecord: No matching catalog thread record found
    /dev/rdisk2s2: GetCatalogRecord: No matching catalog thread record found
    /dev/rdisk2s2: GetCatalogRecord: No matching catalog thread record found

    Do I need to do something else?

  30. Hi Garth,

    the solution seems promising. However (being a newby to the command line), it seems the command does not recognize my sparebundle name as there are spaces in the name. How to solve this?

    name of the sparsebundle ==> MacBook van Joris_2013-03-07-102410.sparsebundle

    You reply is much appreciated!

    Joris

  31. I suspect this means the worst, but here is what I get:

    sh-3.2# fsck_hfs -drfy -c 750 “/dev/disk4s2”
    ** /dev/rdisk4s2 (NO WRITE)
    Using cacheBlockSize=32K cacheTotalBlock=128 cacheSize=4096K.
    Executing fsck_hfs (version diskdev_cmds-491.6~3).
    ** Checking Journaled HFS Plus volume.
    ** Detected a case-sensitive volume.
    BTIterateRecord(945): returning fsBTInvalidNodeErr
    Catalog file entry not found for extent
    (4, 0)
    ** The volume could not be verified completely.
    volume check failed with error 7
    volume type is pure HFS+
    primary MDB is at block 0 0x00
    alternate MDB is at block 0 0x00
    primary VHB is at block 2 0x02
    alternate VHB is at block 683984310 0x28c4c5b6
    sector size = 512 0x200
    VolumeObject flags = 0x07
    total sectors for volume = 683984312 0x28c4c5b8
    total sectors for embedded volume = 0 0x00
    sh-3.2#

    A little background: my MBP’s disk died (under warranty); I restored the system using Migration Assistant (yes, I now know I should have used Setup Assistant); after fixing some permissions, I got .Trash, Spotlight, and time machine to work. That was yesterday: TIme Machine churned away putting — it said — 80 Gb back into the back up that I used to rebuild the system. (The sparsebundle got about 30 Gb bigger, actually.) This morning I used time machine in Star Wars mode to look at the backup. All were there. An hour later, I went to retrieve a file again using the Star Wars interface, but it just sat there. Even rebooting the machine did not help and then I noticed that backups were getting dreaded error 6584. Some poking around and — well the above the current state.

    It seem so near ant yet so far…… I’d hate to loose about a year’s backup.

  32. Garth, thanks for the info. I’m having trouble with the “hdiutil attach…” step – I only get one disk: /dev/disk1.

    I tried repairing that, but still get “No mountable volumes” error when I try to open the sparsebundle.

    Any suggestions?
    Thanks again,
    Michael

      1. Thanks again Garth,

        I ended up taking the drive to a recovery service, and unfortunately, there was too much physical damage (scratched platter) to read the info.

        Lesson for the day: get a backup system with redundancy!

        -Michael

  33. Garth,

    Thanks for your help with this. I think I am on my way to fixing my sparsebundle, but the fsck command has been running for 48 hours now. I am using a Synology NAS. Here is the output from the tail -f command:

    JoeMacPro:~ root# hdiutil attach -nomount -noverify -noautofsck /Volumes/Time\ Machine\ Backups/Renee\ MacBook.sparsebundle
    /dev/disk13 GUID_partition_scheme
    /dev/disk13s1 EFI
    /dev/disk13s2 Apple_HFS
    JoeMacPro:~ root# tail -f /var/log/fsck_hfs.log

    /dev/rdisk12s2: fsck_hfs run at Sun Feb 24 15:38:54 2013
    /dev/rdisk12s2: ** /dev/rdisk12s2 (NO WRITE)
    /dev/rdisk12s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    /dev/rdisk13s2: fsck_hfs run at Tue Feb 26 18:04:51 2013
    /dev/rdisk13s2: ** /dev/rdisk13s2 (NO WRITE)
    /dev/rdisk13s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM DIRTY

    /dev/rdisk14s2: fsck_hfs run at Wed Feb 27 08:08:45 2013
    /dev/rdisk14s2: ** /dev/rdisk14s2 (NO WRITE)
    /dev/rdisk14s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    /dev/rdisk14s2: fsck_hfs run at Wed Feb 27 08:08:56 2013
    /dev/rdisk14s2: ** /dev/rdisk14s2 (NO WRITE)
    /dev/rdisk14s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    /dev/rdisk15s2: fsck_hfs run at Thu Feb 28 03:04:41 2013
    /dev/rdisk15s2: ** /dev/rdisk15s2 (NO WRITE)
    /dev/rdisk15s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    /dev/rdisk15s2: fsck_hfs run at Thu Feb 28 03:04:52 2013
    /dev/rdisk15s2: ** /dev/rdisk15s2 (NO WRITE)
    /dev/rdisk15s2: Executing fsck_hfs (version diskdev_cmds-557.3~1).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    Thanks in advance for any help you can provide,

    Joe

  34. This is a script I took and improved to automatically fix time machine corruptions:


    if [[ $(whoami) == 'root' ]]; then
    USER=hoeve
    read -s -p 'Enter Password:' PASSWORD
    HOSTNAME=10.0.1.16
    AFPSHARE="TM_MBP13"
    TM_NAME=$(hostname -s)

    # Don't change these ...
    MOUNT=/Volumes/TimeMachine
    SPARSEBUNDLE=$MOUNT/${TM_NAME}.sparsebundle
    PLIST=${SPARSEBUNDLE}/com.apple.TimeMachine.MachineID.plist

    echo "Disabling TimeMachine"
    tmutil disable

    echo "Unmounting ${AFPSHARE}"
    while mount | grep ${AFPSHARE} > /dev/null; do mount | grep ${AFPSHARE} | awk '{print $3}' | xargs -n1 -I{} umount -f {}; done

    echo "Mounting volume"
    mkdir $MOUNT
    mount_afp afp://${USER}:${PASSWORD}@${HOSTNAME}/${AFPSHARE} ${MOUNT}

    echo "Changing file and folder flags"
    chflags -R nouchg "${SPARSEBUNDLE}"

    echo "Attaching sparse bundle"
    DISK=$(hdiutil attach -nomount -readwrite -noverify -noautofsck "${SPARSEBUNDLE}" | grep 'Apple_HFS' | awk '{ print $1 }')

    echo "Repairing volume"
    diskutil repairVolume ${DISK}
    /sbin/fsck_hfs -fry ${DISK}

    echo "Fixing Properties"
    cp "${PLIST}" "${PLIST}.backup"
    sed -e '/RecoveryBackupDeclinedDate/{N;d;}' \
    -e '/VerificationState/{n;s/2/0/;}' \
    "${PLIST}.backup" \
    > "${PLIST}"

    echo "Unmounting volumes"
    hdiutil detach ${DISK}
    umount ${MOUNT}

    echo "Enabling TimeMachine"
    tmutil enable

    echo "Starting backup"
    tmutil startbackup

    else
    echo Please run this script as root.
    fi

  35. Thanks so much for this post! I was about to write off netatalk and go back to plugging my external drive in with USB when I found this.

  36. Guys, i was with the same problem with “No such file or directory” i fixed putting the address in ” ” and worked.

    Try this and let us know

  37. Sadly, this doesn’t work for me.
    I tried your latest addition because I got the “RebuildBTree – record 29 in node 112 is not recoverable” error.
    But after running “fsck_hfs -p /dev/diskxs2” and “fsck_hfs -drfy /dev/diskxs2” again it just shows the same problem.
    Any other chance to get this fixed?

    1. @Andreas I was having the same problem, after a successful ‘fsck_hfs -p /dev/diskxs2’ the ‘fsck_hfs -drfy /dev/diskxs2’ as failing again.

      I’ve disconnected the TimeMachine drive and connected again.
      I’ve started the same process again:

      # chflags -R nouchg /Volumes//.sparsebundle
      # hdiutil attach -nomount -noverify -noautofsck /Volumes//.sparsebundle
      # fsck_hfs -drfy /dev/diskxs2

      And this time every this went well, and I didn’t run the ‘fsck_hfs -p /dev/diskxs2’ again.

      My TimeMachine is now backing up.
      Thank you for this tutorial.

    2. I had a similar error showing up as well, but I followed Jorge’s advice of first disconnecting the Time Machine drive, then reconnecting and running those three commands again. My original error never showed up again during the third step like before, and yada yada yada, my Time Machine sparsebundle is error-free and currently backing up my system as I type. Many thanks to both Garth and Jorge!

  38. I am having the same problem as f. pedersen. I do have UTF-8 encoding.

    Peters-MacBook-Pro:TimeMachineBackup root# ls
    .AppleDesktop Network Trash Folder
    .AppleDouble Peter???s MacBook Pro.sparsebundle
    .DS_Store Temporary Items
    ._.DS_Store
    Peters-MacBook-Pro:TimeMachineBackup root# ls “Peter’s MacBook Pro.sparsebundle”
    ls: Peter’s MacBook Pro.sparsebundle: No such file or directory
    Peters-MacBook-Pro:TimeMachineBackup root# ls “Peter???s MacBook Pro.sparsebundle”
    ls: Peter???s MacBook Pro.sparsebundle: No such file or directory
    Peters-MacBook-Pro:TimeMachineBackup root# ls “Peter’s MacBook Pro.sparsebundle”
    ls: Peter’s MacBook Pro.sparsebundle: No such file or directory
    Peters-MacBook-Pro:TimeMachineBackup root# ls “Peter’s MacBook Pro.sparsebundle”
    ls: Peter’s MacBook Pro.sparsebundle: No such file or directory
    Peters-MacBook-Pro:TimeMachineBackup root# ls
    .AppleDesktop ._.DS_Store Temporary Items
    .AppleDouble Network Trash Folder
    .DS_Store Peter???s MacBook Pro.sparsebundle
    Peters-MacBook-Pro:TimeMachineBackup root#

    Any ideas before I give up and create a new backup?

    1. I’ve used this web page several times to recover my ReadyNAS-Time Machine backups. Thank you so much for the research and for posting this page.

  39. After i run “tail -f /var/log/fsck_hfs.log”, the following appears and stay there till now.

    /dev/rdisk2s2: ** /dev/rdisk2s2 (NO WRITE)
    /dev/rdisk2s2: Executing fsck_hfs (version diskdev_cmds-557~393).
    QUICKCHECK ONLY; FILESYSTEM CLEAN

    Is there normal? N roughly how long it will take?

    Thanks.

    1. @Ian – The line ‘QUICKCHECK ONLY; FILESYSTEM CLEAN’ is the last output in that operation. if you see that you can proceed to the repair (drfy) command.

  40. Thanks so much for this! My MBP backs up to a Synology 413 NAS. I was out of town this week, and the MBP attempted a TM backup from the hotel. Not sure why it tried, but I cancelled it. Not sure if that was the cause, but once I returned home and the MBP tried to TM backup, I received the dreaded error described in this article.

    I was having problems entering a curly quote in the file path while following these directions. With the help of user “chrfr” on Macrumors, I discovered the problem. This was his advice, which worked perfectly:

    ***************
    That’s happening because you’re changing from the default shell of bash to sh. Type
    ———
    sudo -s
    ———
    instead of
    ———
    sudo su –
    ———
    to stay in bash, and then everything will work as it normally does.
    ***************

    Additionally, I had to unmount and remount the volume with hdiutil using the -readwrite flag to get fsck to work.

  41. Adrian’s comment above really helped me with the last step, but I think the second line should read:

    defaults write MyFile.sparsebundle/com.apple.TimeMachine.MachineID.plist VerificationState 0

  42. Thank you Man, you also saved my backup. Netatalk 2.2.2 running on rtn-66u . In my case error occured just after I changed wifi connection to different network , while the TM backup was running. Thank you one more time.

  43. After a few hiccups (for some reason “Michael’s MacBook Pro.sparsebundle” was actually named “Michael???s MacBook Pro.sparsebundle”) I was able to get this going and it worked PERFECTLY. THANK YOU GARTH! It’s upsetting that this has been going on for so long and Apple hasn’t even acknowledged it. Fortunately we have brilliant and resourceful people like you coming up with solutions in Apple’s absence. Definitely gonna throw a couple bucks your way via the PayPal link above.

    Again, thanks!!
    Mike

  44. Thanks Garth! I’ve already used your solution here to fix my Time Machine a few times. Today, though, I got the RebuildBTree error that you posted about in your 12.23.2012 update. After running:

    fsck_hfs -p /dev/diskxs2

    It goes through smoothly and I get a “volume was repaired successfully”. In your update you say to do another:

    fsck_hfs -drfy /dev/diskxs2

    This second fsck_hfs continually returns a:

    ** Rebuilding catalog B-tree.
    CreateNewBTree returned 5
    ** The volume Time Machine Backups could not be repaired.
    volume type is pure HFS+
    primary MDB is at block 0 0x00
    alternate MDB is at block 0 0x00
    primary VHB is at block 2 0x02
    alternate VHB is at block 781565870 0x2e95bfae
    sector size = 512 0x200
    VolumeObject flags = 0x07
    total sectors for volume = 781565872 0x2e95bfb0
    total sectors for embedded volume = 0 0x00
    CheckHFS returned 5, fsmodified = 1

    Any ideas? Thanks so much!

  45. Worked like a charm.
    specially your comment to wait and use tail.
    This helped me a lot! Thank you very much.

  46. I tried everything suggested, even the Update from 12.23.2012, but still get:

    RebuildBTree – record 23 in node 1067 is not recoverable.

    ** The volume Time Machine-Backups could not be repaired.

    Any advice what I can do now (I use a TimeCapsule 2TB)?

    1. fsck_hfs always crashes at same point (5 tries now). In Console I get as last message:

      /dev/rdisk1s2: ** Repairing volume.
      Invalid first link in hard link chain (id = 4280704)
      (It should be 4975628 instead of 4834085

Comments are closed.