mmitch / dircompare

list differences between directory trees consisting of hardlinked files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dircompare

List differences between directory trees consisting of hardlinked files.
https://github.com/mmitch/dircompare/

Build Status GPL 3+

usage

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.

see-it-for-yourself example

  1. have a directory dir1
  2. create a recursive copy where all the files are hard links instead of real copies, eg. with cp -rl dir1 dir2
  3. add/rename/move/delete files in dir1 and/or dir2
  4. 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.

original usage scenario

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.

output legend

  • DIR1: file only exists in the first directory tree
  • DIR2: file only exists in the second directory tree
  • REN: file has been renamed
  • MOV: file has been moved to another directory
  • COPIED: 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.

installation

  • Perl
  • the Set::Scalar Perl module

bugs/limitations

If a file is hardlinked multiple times, dircompare will produce erratic results.

copyright

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/.

About

list differences between directory trees consisting of hardlinked files


Languages

Language:Perl 79.6%Language:Shell 18.4%Language:Makefile 2.0%