File Based Backup Verification - Confused About Two Uses Of Diff
https://askubuntu.com/questions/1563277/file-based-backup-verification-confused-about-two-uses-of-diff
I run a file-based backup of my machine as follows:
- Boot into a Live Ubuntu USB
- Mount my system partition (a Logical Volume under LVM) - Call this 'Original'
- Create a fresh 'Backup' LVM and mount that too - Call this 'Backup01'
- RSync from Original to Backup01
That works fine, and I can later boot from my internal drive and send the backup to external storage at my leisure.
To verify the backup, I usually do the following (while booted from the Live USB):
SHA512Sum the entire 'Original' and 'Backup01' LVs. This produces two files (Original.SHA512Sum and Backup01.SHA512Sum)
I then sort both files by path and filename, and then 'Diff' the two sorted files. This produces no output, and thus I (think) I know I have a faithful copy of Original stored in Backup01.
For the avoidance of doubt, both of these commands show the same output:
ls -la /PathTo/Original/
ls -la /PathTo/Backup01/
However, for no obvious reason, today I ran this alternative diff:
diff -rq /PathTo/Original/ /PathTo/Backup01/
However, that command output a load of differences, which is both confusing and concerning.
Questions:
Is my backup method / process robust at all?
Should I expect that the diff on the two directory trees would output no differences, or am I misunderstanding what diff does when you pass it two directories?
Thanks,
Alan.
Edit1: In response to Andrei Borzenkov's request, I checked a specific difference that was identified by 'diff -rq' and am posting here:
lrwxrwxrwx 1 root root 14 Jun 4 2025 /PathToOriginal/bin/iscsiadm -> /sbin/iscsiadm
lrwxrwxrwx 1 root root 14 Jun 4 2025 /PathToBackup01/bin/iscsiadm -> /sbin/iscsiadm
Both of those show as red (coloured) in the terminal, which indicates a broken link. If I try to find the targets of the links, in both cases (Original and Backup01) the target is missing.
I therefore suspected that many of the differences will be broken links, and so I ran:
find /PathToOriginal/ -xtype l -ls
which does in deed show a load of broken links!
I also ran:
diff -rq --no-dereference /PathTo/Original/ /PathTo/Backup01/
This reduces the differences list to almost none, all of the remaining errors being symmetrical (the same difference reported both in Original and Backup01) and having the following error reported:
'is a character special file'
which is not something I have come across before, but indicates that the items are device files, rather than 'regular' files.
Therefore, I think that the issue is resolved, and that trying to use 'diff' in the way I was won't work.