Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Safer sleep during networked Time Machine backups System 10.5
The problem: You have Time Machine set up using a sparsebundle on a network drive, such as a Time Capsule or an AirPort Extreme-connected hard drive. Most of the time, everything works great. Consider this reproducible scenario, however:
  1. You are working away at home and a hourly backup starts. Time machine automagically mounts the sparsebundle.
  2. You need to leave and put your laptop to sleep, not paying attention to the fact that time machine is working.
  3. You move your laptop to work/school and wake it up.
  4. The sparsebundle is still mounted, but obviously does not work. Finder and Spotlight grow increasing stuck until you have to reboot your machine. It occurs to you that the image back home was not closed properly and that eventually, this will corrupt your backups!
  1. Install SleepWatcher (I used the MacPorts build; don't forget to specify the server variant!).
  2. Modify /opt/local/etc/rc.sleep or /etc/rc.sleep to include these two lines:
    logger -t $0 "Ejecting any mounted Time Machine images"
    hdiutil info -plist | grep /Volumes | sed 's/<string>/\"/' | sed 's/<\/string>/\"/'|xargs -I {} bash -c "if test -e \"\$0/Backups.backupdb\";  then hdiutil eject \"\$0\"; fi" {}
I am sure that someone better than I at script-fu can clean up that mess, but basically, it finds disk images that are mounted and are being used for Time Machine, and ejects them. backupd notices this automatically, and cancels the backup gracefully. The image is then safely offline before the machine disconnects from the network, as validated by console logs.
  • Currently 2.44 / 5
  You rated: 1 / 5 (9 votes cast)

10.5: Safer sleep during networked Time Machine backups | 12 comments | Create New Account
Click here to return to the '10.5: Safer sleep during networked Time Machine backups' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Safer sleep during networked Time Machine backups
Authored by: dbs on Nov 19, '08 08:14:30AM

HFS+ volumes (including the disk images used for remote time machine) have a journal which should prevent the disk from becoming corrupted in this scenario. This won't prevent data from being lost (e.g., the last file you were backing up may not get fully written) but your backup volume should not become corrupted. For this to work, however, the journal has to be successfully written to the disk image which is a bit tricky over a network. (This might be part of the reason Apple does not support third-party servers.) If you are seeing corruption in this case you should file a bug report with Apple so they can look into it. Personally, I've been running this way for a while and haven't seen any corruption when I verify my time machine disk image, but I'm only backing up over a wired network.

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: jsteinhu on Nov 19, '08 10:16:53AM

I am the original poster, I had not created my macosxhints account before submission. I can attest that the corruption does in fact occur, and also that when the image is unmounted correctly it destabilizes the machine when you wake up on another network. Because these are all timing issues the problems won't show up each and every time but when you switch networks as often as I do it is a problem.

I am not sure exactly which of the sleepwatcher diskimages you want to install, I used macports. I believe that StartupItem is depreciated and is for older versions of OSX, like 10.2. The readme file in the disk image should clue you in.

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: wsdr on Nov 19, '08 08:19:35AM

I'll be trying this. I have had this issue a number of times -- and have had my backup disk image get corrupted. In the past I have nuked the image and started over, but this would avoid that issue. BTW: I keep two different TimeMachine backups and switch between the two periodically, which is why I don't sweat it when one gets corrupt.


[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: cnf on Nov 19, '08 08:40:55AM

This scenario is something that fits my daily routine very nicely. It has never gone wrong for me though. Finder sees I am on a different network, and disconnects the sparebundle, and the next time I am home, TM cleans up the last mess, and just goes on...

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: julianlove on Nov 19, '08 09:10:32AM

The problem described definitely exists. I had a corrupted time capsule backup a few months ago while I was working in 2 different locations, and had to nuke it and start again from scratch - which kind of defeats the purpose of a backup... And if you search the support forums for the time capsule, you'll find lots of others having the same problem.

Being a non-tech, I don't know which bit of sleepwatcher I install - the regular .pkg or the startupitem.pkg ....any ideas?

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: mayo2ca on Nov 19, '08 10:04:16AM

One workaround around this is changing your locations (I do it anyway depending on where I am). So when I'm at home and sleep the machine while it's doing backup, go to work, wake it up, change the location to Office, the backup will terminate and say it failed, but it will not hang the machine. Also, there will be no corrupted backup on the TC. I of course change the location back to Home when I get home.

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: mezis on Nov 19, '08 12:19:57PM

The scenario described in this hint fits our setup here at work.

We have everal non-tech-savvy laptop users having TM backups to an AFP share on a server, any we never experienced any problem....

other than storage size issues, I mean :)

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: PCheese on Nov 19, '08 05:22:35PM

I've gotten backup corruption three times (two separate machines) with similar scenarios. I back up to a Time Capsule and close the lid without checking the Time Capsule state. I do this regularly enough that after a few weeks the sparsebundle won't even mount anymore.

My current solution is to manually start backups from the menu bar, but I might try this alternative.

[ Reply to This | # ]
Count me corrupt
Authored by: dan55304 on Nov 20, '08 05:14:33AM

I had this corrupt my networked TimeMachine several times. I just wasn't used to having my laptop tethered to a remote volume. I finally gave up and moved my TimeMachine HD next to my laptop. Now, at least, I can't walk away without pulling the plug on something. Even so, I still frequently forget and just unplug the USB connector and walk away. There hasn't been any corruption since doing TimeMachine via connected USB drive.

[ Reply to This | # ]
Fine advice, but unnecessary
Authored by: GaelicWizard on Nov 20, '08 01:55:33PM

The advice in this hint won't hurt anything, but it is also unneeded. I notice that several of the commenters above me have seen this issue, as have I. These issues did plague the brand-new Time Machine and Time Capsule when first released, but have been resolved.

Since around 10.5.4, and moreso with 10.5.5, Time Machine does correctly notice network changes and will unmount the volume. Also, the method by which the disk image is stored on the Time Capsule (sparse bundle), is largely immune to corruption (although nothing is perfect).

Also, several updates to the Time Capsule firmware have been released. I believe that we are on 7.3.2 now. Some of these updates did specifically list Time Machine improvements. As I mentioned above, I did have corruption issues once. I updated all my software, updated my TC firmware, and created a new sparsebundle and haven't had any trouble since.

Time Machine should, can, and does correctly disconnect from a Time Capsule when the network drops.

Of course, following this hint doesn't hurt anything either, so if you would feel safer with this method, then do it!


P.S. Judging from the NDA-violating postings of release notes from 10.5.6, the last remnants of the <del>old republic</del> Time Machine / Time Capsule bugs should be eliminated.


[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: hamarkus on Dec 01, '08 02:31:43PM

Where do have to insert these two lines in the script? Anywhere, except inside some already existing loop?

And this is a real problem. Maybe other people are more patient than I am. I had severe problems multiple times with my TC, essentially it remains stuck in 'Preparing' forever or finally even fails to mount. At one moment a recreation of the Spotlight index on the TC solved it, another time DiskWarrior took two days fixing the mounted image. At last even DiskWarrior gave up (after gobbling up 3 GB of RAM). Apple gave me a new TC (but they were not authorized to open the TC to see whether the drive would still mount in Firewire enclosure, essentially I lost my nine month old archive). Now the new TC again got stuck after I mounted the TM backup and then disconnected the TC.

[ Reply to This | # ]
10.5: Safer sleep during networked Time Machine backups
Authored by: miker71 on Dec 05, '08 05:22:02AM

Great! This seems to have resolved a problem I was having using a drive on my Airport N Base Station to do Time Machine backups.

The PowerBook is 10.5.5, the Airport is 7.3.2 IIRC.

Put the PowerBook to sleep whilst Time Machine is running and the Airport would puke on any further filesharing, Airport Utility would have problems connecting to it. Internet connection would remain okay.
Until the Airport is reset, no further Time Machine backups possibe due to the filesharing FUBAR.

After this hint:
Put the PowerBook to sleep whilst Time Machine is running and Airport filesharing is unaffected. Wake the PowerBook and you are greeted by a Time Machine dialogue informing you the network connection was lost.

Note that I did not edit the rc.sleep file, I just put the hint commands into ~/.sleep (along with #!/bin/bash )and did a chmod a+x on .sleep

I installed both sleepwalker packages, though no idea if I needed to or not ....

[ Reply to This | # ]