Nov 19, '08 07:30:00AM • Contributed by: jsteinhu
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:
- You are working away at home and a hourly backup starts. Time machine automagically mounts the sparsebundle.
- You need to leave and put your laptop to sleep, not paying attention to the fact that time machine is working.
- You move your laptop to work/school and wake it up.
- 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!
- Install SleepWatcher (I used the MacPorts build; don't forget to specify the server variant!).
- 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" {}
