{"id":1990,"date":"2009-08-07T22:11:05","date_gmt":"2009-08-07T20:11:05","guid":{"rendered":"http:\/\/tokao.com\/?p=1990"},"modified":"2009-08-07T22:11:05","modified_gmt":"2009-08-07T20:11:05","slug":"how-to-fix-a-corrupted-time-machine-backup","status":"publish","type":"post","link":"https:\/\/tokao.com\/wordpress\/2009\/08\/07\/how-to-fix-a-corrupted-time-machine-backup\/","title":{"rendered":"How to fix a Corrupted Time Machine Backup"},"content":{"rendered":"<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">The other day time machine decided to stop working for me and kept giving me errors about mounting the backup image. After firing up Console.app I found that the sparsebundle which time machine stores the backup data in was corrupted. This is a bad thing since if I couldn\u2019t find a way to fix the image all my backups for the last 6 months would be lost\u00a0<img decoding=\"async\" src=\"http:\/\/blog.jthon.com\/wp-includes\/images\/smilies\/icon_sad.gif\" alt=\":(\" \/> .<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">My first step on the road to fixing the problem was to open the bundle with \u201cDisk Utility\u201d and see if repair disk would work. To do this you need to drag the back image (the .sparsebundle) and drop it on disk utility. Then you can select the image and press \u201cRepair Disk\u201d. Usually if if you have some disk corruption this would fix it, but not for me.<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">After working for a couple minutes Disk Util would fail at repairing the disk since it found an \u201cInvalid Sibling Link\u201d. It seems the disk was corrupted and the disk repair utility decided it wasn\u2019t going to repair it. Worried that my backups were gone for good I did some Googling and found that this problem isn\u2019t totally uncommon. It seems that Disk Utility is just fairly bad at repairing disks and that using the \u201creal\u201d disk repair utility\u00a0<tt>fsck_hfs<\/tt> might actually fix the problem.<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">Of course there\u2019s one problem\u00a0<tt>fsck_hfs<\/tt> has to be used directly on a block device not a \u201csparsebundle\u201d disk image. Not only that but the volume you run the util on cannot be mounted and OS X always tries to mount the image when you click on it. The solution? Use the command line tool\u00a0<tt>hdiutil<\/tt> to \u201cattach\u201d but not \u201cmount\u201d the image. This makes OS X create a\u00a0<tt>\/dev\/<\/tt> device for the sparse bundle but doesn\u2019t actually mount the filesystem.<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">So combining\u00a0<tt>hdiutil<\/tt> and\u00a0<tt>fsck_hfs<\/tt> we might have a way to fix the disk image. Note: Make sure you turn off Time Machine in the System Preferences panel. We don\u2019t want Time Machine trying to mount our image and back up to it until we\u2019re done making all the repairs.<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">First I ran\u00a0<tt>hdiutil<\/tt>:<\/p>\n<pre>hdiutil attach -nomount -readwrite Bhaal_0011247e3338.sparsebundle<\/pre>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">After a minute or two of thinking we had success:<\/p>\n<pre>\/dev\/disk1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Apple_partition_scheme\n\/dev\/disk1s1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Apple_partition_map\n\/dev\/disk1s2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 Apple_HFSX<\/pre>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\">The next step was run\u00a0<tt>fsck_hfs<\/tt> on the main volume.<\/p>\n<pre>fsck_hfs -rf \/dev\/disk1s2<\/pre>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 1.5em; padding: 0px;\"><tt>-f<\/tt> is required to force a check since this is a journaled file system. I also used\u00a0<tt>-r<\/tt> to have it rebuild the filesystem catalog for the \u201cinvalid sibling link\u201d this is required (thanks Dan). At this point I went out for breakfast since I was running a disk repair utility over my wireless internet to my Linux SAMBA server. After coming back from breakfast we had success!<\/p>\n<pre>** \/dev\/rdisk1s2\n** Checking Journaled HFS Plus volume.\n** Detected a case-sensitive catalog.\n** Checking Extents Overflow file.\n** Checking Catalog file.\n** Rebuilding Catalog B-tree.\n** Rechecking volume.\n** Checking Journaled HFS Plus volume.\n** Detected a case-sensitive catalog.\n** Checking Extents Overflow file.\n** Checking Catalog file.\n   Incorrect number of thread records\n(4, 13716)\n** Checking multi-linked files.\n** Checking Catalog hierarchy.\n   Invalid directory item count\n   (It should be 0 instead of 1)\n   Invalid directory item count\n   (It should be 3 instead of 4)\n   Incorrect folder count in a directory (id = 3795486)\n   (It should be 0 instead of 1)\n** Checking Extended Attributes file.\n** Checking multi-linked directories.\n** Checking volume bitmap.\n** Checking volume information.\n   Invalid volume free block count\n   (It should be 37267681 instead of 37310834)\n   Volume Header needs minor repair\n(2, 0)\n** Repairing volume.\n** Rechecking volume.\n** Checking Journaled HFS Plus volume.\n** Detected a case-sensitive catalog.\n** Checking Extents Overflow file.\n** Checking Catalog file.\n** Checking multi-linked files.\n** Checking Catalog hierarchy.\n** Checking Extended Attributes file.\n** Checking multi-linked directories.\n** Checking volume bitmap.\n** Checking volume information.\n** The volume Backup of Bhaal was repaired successfully<\/pre>\n<pre>(extracted from <a href=\"http:\/\/blog.jthon.com\/?p=31\" target=\"_blank\">jthon.com blog<\/a>)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The other day time machine decided to stop working for me and kept giving me errors about mounting the backup image. After firing up Console.app I found that the sparsebundle which time machine stores the backup data in was corrupted. This is a bad thing since if I couldn\u2019t find a way to fix the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[29,8],"class_list":["post-1990","post","type-post","status-publish","format-standard","hentry","category-technology","tag-mac","tag-tips"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/posts\/1990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1990"}],"version-history":[{"count":0,"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/posts\/1990\/revisions"}],"wp:attachment":[{"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tokao.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}