Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
When Time Machine asks you to delete your backups and start over, ignore it. Run this and then start a backup again.
#!/bin/bash -x
# Generally based on ideas found at:
# Reduced the ideas there down to their essentials.
# 1. Unlock the image.
# 2. Reset the saved failure in the backup metadata.
# 3. Verify/fix the filesystem.
# Take the arg. You did provide an arg, right?
if [ -z "$IMAGE" ]; then echo "usage: $0 image_path"; exit; fi
# Repair the stupid file lock.
chflags -v nouchg "$IMAGE"
chflags -v nouchg "$IMAGE/token"
chflags -v nouchg "$IMAGE/bands"
# Fix the plists
/usr/libexec/PlistBuddy -c "Delete :RecoveryBackupDeclinedDate" "$IMAGE/"
/usr/libexec/PlistBuddy -c "Set :VerificationState 0" "$IMAGE/"
# Start bailing on errors (can't set earlier due to PlistBuddy)
set -e
# Attach the image.
DEV=`hdiutil attach -nomount -noverify -noautofsck "$IMAGE" | awk '/HFS/ {print $1}'`
echo "$IMAGE -> $DEV"
# Fix the FS.
fsck_hfs -fy -c 8gb "$DEV"
# Detach it.
hdiutil detach "$DEV"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.