David Hlác(ik wrote:
Hello guys,
I have two mirrors. I need to compare files and directories on both mirrors and as a result print list of those which are missing on mirror 2
What i did
find /data > find.mirror1
find /data > find.mirror2
Now i need to get list of those directories which are missing in mirror1.
You can run diff with the two files, but why not just use rsync to fix it in a single step?
To compare directories with rsync, cd into one of them and: rsync -avn . /target/path The -n option says to not actually copy files, but with the -v option this will list the files that are missing or different. Because the -a option also sets the owner and modes, this may list files where those are the only differences. Omit the -n option to make the changes.
The target path may be on a different host if you use the form user@host:/path/to/target. With older versions of rsync you might have to add -essh to the arguments but that is the default now. If you would like any extra files in the target copy to be deleted, you can add the --delete option, but be sure you know what you are doing first.