List differences between directory trees consisting of hardlinked files.
https://github.com/mmitch/dircompare/
If you have a set of hardlinked backups like those generated by
rsnapshot(1)
, you could run dircompare daily.0 daily.1
to see what
has changed between those two generations:
- Which files differ?
- Which files have been renamed or moved?
- Which files are new or have been removed?
dircompare works by looking at the hardlink status of the files without checking the file content.
- have a directory
dir1
- create a recursive copy where all the files are hard links
instead of real copies, eg. with
cp -rl dir1 dir2
- add/rename/move/delete files in
dir1
and/ordir2
- run
dircompare dir1 dir2
to see what has changed
Two files are only recognized as equal when they are still
hardlinked. See test/test.sh
for an more elaborate example setup
and test/expected
for the associated output from dircompare.
I have a 16GB USB dongle full of MP3s to listen to in my car. I have a full copy of the stick on my hard drive and add and remove songs to/from the collection on my PC.
With dircompare I can see what I have changed compared to the last full copy of the USB dongle. I then manually copy those changes to the dongle to keep it in sync without the need to copy the full 16GB every time.
Afterwards I do a cp -rl
of the current tree on my hard drive as a
new baseline for the next compare.
DIR1
: file only exists in the first directory treeDIR2
: file only exists in the second directory treeREN
: file has been renamedMOV
: file has been moved to another directoryCOPIED
: name and subdirectory match between both trees, but the file is no longer hardlinked but a real, separate copy
REN
, MOV
and COPIED
are displayed in pairs: the first line shows
the filename in the first directory tree, the second line shows the
filename in the second directory tree.
Unchanged files (same name, same relative location) are not displayed at all.
- Perl
- the
Set::Scalar
Perl module
If a file is hardlinked multiple times, dircompare will produce erratic results.
Copyright (C) 2019 Christian Garbs mitch@cgarbs.de
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.