cmp(1) will of course tell me if the contents of two files are identical, but in order to test restoring from backups I also wanted to compare the relevant (!) file attributes.
So if I did something simple like
mv foo.bar foo.bar.save
deja-dup --restore foo.bar # or some other backup tool
how do I compare the attributes of foo.bar and foo.bar.save and test for sufficient equality in a shell script (or similar). I can do
stat foo.bar{,.save}
and manually inspect the output remembering to ignore inode, atime, and ctime (as well as link count, for some reason?), but this is error prone. Is there a cmp-with-attributes tool somewhere which include SELinux and other attributes? Must work on Fedora and ext4 file systems; ideally on "all" systems. Do I need to hack something up in perl?
(No point having backups if you don't test that they work right.)


stathas two options,-cor--format, and--printf, that you can use to make it print the data you are interested in, in the format you want, so you can later compare it withdiffor another tool. – angus Aug 29 '12 at 9:03