First off, I am running restic 0.16.0 compiled with go1.20.6 on darwin/amd64. I have a backup script that runs Restic on two repos. I backup my photos to iDrive e2 and OneDrive. The commands are identical, and run sequentially. iDrive is via the AWS built-in backend, and OneDrive is via the Rclone backend.
I recently discovered a hashing app called cshatag. In a nutshell, it computes the SHA-256 hash of a given file / directory, then embeds the hash AND modified date as an extended attribute. Later, if you want to check for bitrot, you can run it, and if the modified date has changed, it will report it and update the hash, but not report an error. BUT if the hash has changed and the modified date has NOT, it will report an error. I had previously used rhash which embeds the CRC32 in the filename, but I thought this might be more efficient since it also makes note of modification times.
So. I wanted to try it out. But I wanted a backup first, obviously. So I run my script. I then run the utility. I then run ANOTHER backup, for the sake of it. And, for some reason… they were different? I noticed the MiB backed up seemed to differ more than I would expect. So I went to investigate.
Here’s the snapshots from the iDrive e2 backup, which runs first:
7d1b1ae9 2023-08-25 08:50:43 Media b4_cshatag
cd80c861 2023-08-25 13:01:03 Media
Here’s the snapshots from the OneDrive backup, which runs immediately after:
02325856 2023-08-25 08:55:35 Media b4_cshatag
e56139a9 2023-08-25 13:57:56 Media
Straightforward enough. I hadn’t really used extended attributes much, so I was curious how Restic would handle it. I ran a diff
on both sets. Here’s the output of iDrive e2:
comparing snapshot 7d1b1ae9 to cd80c861:
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 19-12-27 [C9DA9557].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 20-04-34 [01872D07].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 20-23-45 [CA2A724D].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-15 13-24-00 [BB5E49AD].avif
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-15 16-09-03 [C83747CA].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-16 08-23-06 [F9EFC965].webp
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/Mark’s iPhone 13 Mini/2023-05-05 08-37-15 [B6130405].heic
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/Mark’s iPhone 13 Mini/2023-05-05 14-46-46 [5155965E].heic
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (SAHS Band)/IMG_3952 [CCD356CA].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0001 [2CC5C403].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0003 [AC7B8288].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0004 [A1A2645F].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0005 [901D19E0].JPG
Files: 0 new, 0 removed, 13 changed
Dirs: 0 new, 0 removed
Others: 0 new, 0 removed
Data Blobs: 85 new, 100 removed
Tree Blobs: 6301 new, 6301 removed
Added: 303.307 MiB
Removed: 289.573 MiB
And the output of OneDrive:
comparing snapshot 02325856 to e56139a9:
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 19-12-27 [C9DA9557].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 20-04-34 [01872D07].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-14 20-23-45 [CA2A724D].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-15 13-24-00 [BB5E49AD].avif
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-15 16-09-03 [C83747CA].mov
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-02-16 08-23-06 [F9EFC965].webp
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-05-05 08-37-15 [B6130405].heic
M /Volumes/Media/Photos & Videos/_Incoming/3_Hashed/iPhone 13 Mini/2023-05-05 14-46-46 [5155965E].heic
Files: 0 new, 0 removed, 8 changed
Dirs: 0 new, 0 removed
Others: 0 new, 0 removed
Data Blobs: 74 new, 88 removed
Tree Blobs: 6301 new, 6301 removed
Added: 287.092 MiB
Removed: 273.358 MiB
So, for some reason, the following were modified in the FIRST backup to iDrive e2, but NOT modified in the SECOND backup to OneDrive? That made no sense…
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (SAHS Band)/IMG_3952 [CCD356CA].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0001 [2CC5C403].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0003 [AC7B8288].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0004 [A1A2645F].JPG
M /Volumes/Media/Photos & Videos/_To Sort/!Images/Pictures/2010/2010-08-21 (Selfies)/IMG_0005 [901D19E0].JPG
So, I restored all six images from both snapshots to compare. Very quickly I saw that the FIRST snapshot from iDrive e2 was corrupt. The images didn’t load, the CRC32 didn’t match, nor did the SHA-256 match (obviously). The SECOND snapshot on OneDrive, which occurred immediately after, was perfectly fine. Then I checked the files on my actual SSD. They checked out fine as well. They load correctly, and the two hashes match.
This makes no sense to me. There were no errors reported on either backup. I never even would have noticed if I wasn’t backing up to two repos and noticed the MiB added differed. And the snapshot with the corrupted files… took place BEFORE the snapshot with the OK files.
I am going to run another snapshot on both repositories, adding the --force
switch for good measure. I may run yet another one after that, after emptying Restic’s cache, as well, to see what difference that makes. I’ll report back with the diff’s once I’m done.
I’m also immediately going to make some old-fashioned duplicity + par2 backups as well