Skip to content

Instantly share code, notes, and snippets.

@mxl
Last active May 12, 2022 21:14
Show Gist options
  • Save mxl/22dc8d5766f5f3c3c7ecdd011c86d107 to your computer and use it in GitHub Desktop.
Save mxl/22dc8d5766f5f3c3c7ecdd011c86d107 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BACKUP_PATH=$1
if [ -z "$BACKUP_PATH" ]; then
echo "Please provide path to Time Machine backup bundle."
exit 1
fi
echo "More info at https://jd-powered.net/notes/fixing-your-time-machine-backup/"
echo "Don't forget to enable Full Disk Access in System Preferences -> Security & Privacy -> Privacy tab -> Full Disk Access -> check Terminal or iTerm item"
chflags -R nouchg "$BACKUP_PATH"
VOLUME_ID=$(hdiutil attach -nomount -noverify -noautofsck "$BACKUP_PATH" | grep "Apple_HFS" | awk '{print $1}')
fsck_hfs -drfy "$VOLUME_ID"
hdiutil detach "$VOLUME_ID"
sed -i '' -e '/<key>VerificationState<\/key>/ {' -e 'n; s/<integer>.*<\/integer>/<integer>0<\/integer>/' -e '}' "$BACKUP_PATH/com.apple.TimeMachine.MachineID.plist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment