I have two servers, a production server and a cloned image of the production server. There is some difference in the cloned image that is preventing it from working. I'd like to have a list of the differences.

The servers are on different networks so I can't easily compare them. What I need is a something which will create a database of the checksums on the production server and clone server and compare them.

Is there already something that can do this? Or is it easier to write a script to do this?

  • 1
    What kind of files is it? Config files? If so you some tool to manage same configuration (cfengine, puppet or simple VCS like git...). If data, just rsync, isn't this enough?
    – jirib
    May 29 '12 at 9:02
  • Remember that calculating md5 on hole filesystem can last very very long so better use this on concrete directory.
    – B14D3
    May 29 '12 at 9:05

At each server as root:

find / -type f -exec md5sum {} \; >server-foo.com-files.txt

Then copy those files to your workstation or whatever and

diff -U0 server-foo.com-files.txt otherserver-foo.com-files.txt

That will show you the differences between MD5 sums.

  • Don't you need to sort the output (find doesn't necessarily generate the names in a predictable order).
    – Paul Cager
    May 29 '12 at 14:13

I'd go with rsync (which will also update the files if you tell it to):

 [root@local ~]# rsync -avn user@remote:/somedir /somedir
  • That's a very incomplete answer. May 29 '12 at 11:01
  • 3
    Compared to the straightforward find/md5sum/diff, using rsync is a really nice idea.
    – Oliver
    May 29 '12 at 11:51
  • Duh, should have thought about this. :-) May 29 '12 at 12:13
  • Incomplete because it misses the -c option which is probably preferrable to normal rsync algorhythms for that purpose. May 29 '12 at 14:45

We have a tool that runs diff algorithms between multiple servers. It can also be scheduled to do daily or hourly diffs as a way to watch for unexpected changes. It's in free beta right now, http://metaforsoftware.com, hope it can help you. (Full disclosure: I'm a co-founder)

  • Hey, guys don't downv ote this solution just because it is commercial product. I didn't specify a free solution. May 22 '13 at 5:32
  • thanks @StuartWoodward. We plan to always have a free version available so we can help more people with their diff problems :)
    – jyang
    Jun 8 '13 at 4:58

You can use diff to compare files (you will need to write a simple scipt that will check all files in some directories that you want to check and write output to log file).

Also you can use md5sum to calculate md5s for every file and then find files that differs and use diff on them to find out the differences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.