Mac – Time Machine error code 21 and 19, “Failed to mount… because the image could not be attached”

backupnastime-machine

With macOS sierra (10.12.4), Time Machine backups to a Synology NAS are failing in the "preparing backup" phase. The UI messages aren't helpful, but console shows this error from backupd:

Failed to mount '/Volumes/TimeMachine/fubar.sparsebundle'
because the image could not be attached, error:
Error Domain=com.apple.backupd.ErrorDomain Code=21 "(null)"
UserInfo={MessageParameters=(
    "/Volumes/TimeMachine/fubar.sparsebundle",
    19
)}

This repeats every 60 seconds for several minutes, and then Time Machine gives up.

I'm familiar with the sort of problem fixed by https://apple.stackexchange.com/a/39842/30668 but this seems to be different. I can mount the network volume and attach the sparsebundle. Running fsck shows no errors. The sparsebundle plist shows VerificationState 0, and doesn't have a RecoveryBackupDeclinedDate.

Best Answer

This turned out to be a keychain problem. Possibly I changed the NAS login password and never updated keychain.

  1. Settings > Time Machine > Stop using "TimeMachine" for Backup
  2. Keychain > search for NAS hostname and delete all matching passwords. I think the problem entries were in the System keychain, but I also deleted entries from the login keychain.
  3. Settings > Time Machine > Add Backup Disk... > select "TimeMachine" > enter password

This situation was confusing because the messages from Time Machine didn't say anything about authentication, and Finder could connect to the NAS volume ok. But apparently backupd uses a different Keychain entry, which was bad or wrong.