Simon Heimlicher

Simon Heimlicher's Homepage

Time Machine: UUID of Disk Changed

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:

backupd Backup failed with error: 12
backupd 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.

Note

Starting from OS X Lion 10.7, there is a nifty new command line utility called tmutil, which takes care of the task previously accomplished by the script described below. Here is an example of how to use tmutil to associate a new disk with an existing backup.

Note

Mac OS X 10.6 Snow Leopard has ACLs enabled by default and therefore ships without the fsaclctl command line tool that we need to temporarily turn off ACLs. You may try to grab it from a Leopard DVD: http://porkrind.org/missives/how-to-get-fsaclctl-off-your-leopard-install-dvd/

Use this at your own risk!

Usage Example

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

Script

And here’s the script.

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

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

1
chmod +x "timemachine-setuuid.sh"

Comments