0

I have two Centos 7 boxes where there is an identical folder structure on each. The files between them are meant to be same.

However because of replication issues I want to check to see what files are missing from Server B that exists Server A between two dates. If any files are missing to make a copy to another folder on Server A where they then be copied into Server B in one go

5
  • "that exists Server A between two dates". You can only find files that still exist now, not files that existed between two dates. May 14, 2020 at 14:53
  • Can't you use the timestamp of when they were written
    – Andy5
    May 14, 2020 at 16:00
  • If the file still exists, yes. But not for files that have been removed since the second date. May 14, 2020 at 18:14
  • I think I can live with that because replication only happens once a week. So is there a way I could do this
    – Andy5
    May 14, 2020 at 18:16
  • check my answer May 14, 2020 at 18:22

1 Answer 1

0

Run this command to find the files modified (eg. written to) between 10 and 5 days ago, eg. on server A

cd /identic/directory/
find . -type f -mtime -10 -mtime +5  > /tmp/files_A.txt

Do the same on server B, except for the filename, obvious, /tmp/files_B.txt

Copy one of the files to the other system's /tmp folder and run

cd /tmp
diff files_[AB].txt  | less -X

This will give you missing files.

If you want to check file sizes and modification times, add the "-ls" option to find:

find . -type f -mtime -10 -mtime +5  -ls > /tmp/files_A.txt

You may need to play with the number of days, they are counted from the current time(!), not day.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .