Time machine UUID of disk changed

Time Machine: UUID of disk changed

Update

The problem described in this article is now being handled by macOS. In most cases, you are given the option to associate the Time Machine disk and inherit the backup history.

If you clone a volume that you backup with Time Machine, its UUID will change and Time Machine will no longer be able to make backups of it. However, it won’t tell you directly what the problem is. Rather, you will find entries like the following in /var/log/system.log:

1backupd Backup failed with error: 12
2backupd Error (12): Link of previous volume failed for macosx.

If you want to continue to backup to the same volume in your Time Machine backup database, the following script allows you to change the UUID of the existing backups, leading Time Machine to backup as if the volume’s UUID had never changed.

 1./timemachine-setuuid.sh "Backup of MyMac" "Macintosh HD"
 2
 3Using Time Machine volume
 4  "/Volumes/Backup of MyMac"
 5with backup database located at
 6  "/Volumes/Backup of MyMac/Backups.backupdb/MyMac"
 7
 8UUID of volume "Macintosh HD" will be set to "394FBC68-AA00-3556-81B5-D61F5BFA27ED"
 9
10Done
Example usage

And here’s the script.

 1#!/usr/bin/env bash
 2set -u; set -e
 3
 4# From: http://www.macosxhints.com/article.php?story=20090213071015789
 5# All credits go to the author "only_solutions ()". Their profile is at
 6# http://www.macosxhints.com/users.php?mode=profile&uid=1060791
 7
 8if [[ $# -ne 2 ]]; then
 9    echo "Usage: `basename "$0"` `<Time Machine volume, e.g. \"Backup of My Mac\">` `<Disk whose UUID needs to be set, e.g. \"Macintosh HD\">`"
10		exit 1
11fi
12
13errxit () {
14    [[ "$2" ]] && printf "$2\n" >&2
15    exit ${1:-1}
16}
17
18say () {
19    msg="${1-`}"
20    [[ ! -z "$msg" ]] && printf "$msg\n" >&2
21}
22
23# Check if Time Machine volume is mounted in /Volumes
24TMV="$( cd "/Volumes/$1" && pwd )"
25
26# Check if source volume is mounted in /Volumes
27SRCVOLUME="$( cd "/Volumes/$2" && pwd )"
28
29# Strip '/Volumes' to obtain source volume name
30VOLNAME="${SRCVOLUME#/Volumes/}"
31
32# Get source volume UUID
33UUID="$( diskutil info "$SRCVOLUME" | sed -nE 's/.*Volume UUID: +([-A-F0-9]+).*/\1/p' )"
34
35# Get path to backup database
36BDB="$TMV/Backups.backupdb/$(scutil --get ComputerName)"
37if ! ls "$BDB" &>/dev/null; then
38    errxit 1 "Invalid backup database path:
39  \"$BDB\""
40fi
41
42if ! ls "$BDB/"*/"$VOLNAME" &>/dev/null; then
43    errxit 1 "Volume \"$VOLNAME\" not found in backup database at
44  \"$BDB\""
45fi
46
47say "Using Time Machine volume
48  \"$TMV\"
49with backup database located at
50  \"$BDB\"
51
52UUID of volume \"$VOLNAME\" will be set to \"$UUID\"
53"
54
55# Disable ACL protection on Time Machine volume
56sudo fsaclctl -p "$TMV" -d
57
58sudo xattr -w com.apple.backupd.SnapshotVolumeUUID "$UUID" \
59    "$BDB"/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-*/"$VOLNAME"
60
61# Re-enable ACL protection on Time Machine volume
62sudo fsaclctl -p "$TMV" -e
63
64echo "Done"
Shell script timemachine-setuuid.sh

Save the above code to a file called e.g. timemachine-setuuid.sh and make that file executable by issuing

1chmod +x "timemachine-setuuid.sh"