I'm about to remove an old backup directory, but before doing so I'd like to make sure that all these files exist in a newer directory.
Is there a tool for this? Or am I best off doing this "manually" using find
, md5sum
, sorting, comparing, etc?
Clarification:
If I have the following directory listings
/path/to/old_backup/dir1/fileA
/path/to/old_backup/dir1/fileB
/path/to/old_backup/dir2/fileC
and
/path/to/new_backup/dir1/fileA
/path/to/new_backup/dir2/fileB
/path/to/new_backup/dir2/fileD
then fileA
and fileB
exists in new_backup
(fileA
in its original directory, and fileB
has moved from dir1
to dir2
). fileC
on the other hand is missing in new_backup
and fileD
has been created. In this situation I'd like the output to be something like
fileC exists in old_backup, but not in new_backup.
I'd make my own tool. Go the manual route for this one with some fancy find-ings:
That's incredibly sloppy, but the basic algorithm should be alright. You could also do some catting to figure out which files didn't have copies in both like so:
I can explain the bits and pieces if you need.
Python has some nice standard library modules for this called dircmp/filecmp.
From Doug Hellmann's PyMOTW, This little bit of code gives you:
Gives you:
Doug explains the full skinny on filecmp/dircmp way better than I can at:
http://www.doughellmann.com/PyMOTW/filecmp/
I like python for things like this because it ports much more easily between Linux/Windows/Solaris for me than anything shell based.
Use diff -uRN dir1 dir2
The diff will be empty if the files are perfect... Or it'll show!