Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # http://www.garth.org/archives/2011,08,27,169,fix-time-machine-sparsebundle-nas-based-backup-errors.html
- BUNDLE=???
- set -e
- date
- echo 'chflags...'
- chflags -R nouchg "$BUNDLE/"
- date
- echo 'hdutil...'
- DISKS=`hdiutil attach -nomount -noverify -noautofsck "$BUNDLE/"`
- echo $DISKS
- HFS_DISK=`echo $DISKS | grep Apple_HFS | cut -f 1 | tr -d ' \t'`
- echo "identified HFS(X) volume as $HFS_DISK"
- date
- echo 'fsck...'
- fsck_hfs -drfy $HFS_DISK
- # this was to wait for the log to finish before we ran fsck explicitly, as above
- # grep -q 'was repaired successfully|could not be repaired' <(tail -f -n 0 /var/log/fsck_hfs.log)
- date
- echo 'fixing plist...'
- cat "$BUNDLE/com.apple.TimeMachine.MachineID.plist" |
- # change VerificationState to zero
- awk 'BEGIN { RS = "" } { gsub(/VerificationState<\/key>[ \t\n]*<integer>2/, "VerificationState</key>\n\t<integer>0"); print }' |
- # remove RecoveryBackupDeclinedDate and write to a temp file
- awk 'BEGIN { RS = "" } { gsub(/[ \t\n]*<key>RecoveryBackupDeclinedDate<\/key>[ \t\n]*<date>[^<]+<\/date>/, ""); print }' > /tmp/fixed-plist.plist
- # replace the original (don't use mv; it throws weird errors when moving across this disks)
- cp /tmp/fixed-plist.plist "$BUNDLE/com.apple.TimeMachine.MachineID.plist"
- rm /tmp/fixed-plist.plist
- date
- echo 'done!'
- echo 'eject the disk from your desktop if necessary, then rerun Time Machine'
- # this command will tell you who's using the disk, if ejecting is a problem:
- # sudo lsof -xf +d /Volumes/disk<?> # or possibly just $BUNDLE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement