Saturday, October 13, 2012

Comparing directories between 2 Linux systems

This is a continuation of my previous post on comparing directories using 'diff' command that are Local.
However on several occasions I faced situations, where I need to compare the file configuration between 2 Linux machines (especially in Application servers). In those scenario what I normally used to do was, copy the entire directory from server to another and run the 'diff' command as shown in the previous post. It was obviously a tedious task. Eventually I found a solution to simplify this task by using 'sshfs', which is Secure SHell FileSystem (refer 'man sshfs' for more details).

Steps to compare Folders in 2 machines. Let's assume the local folder name "/dir1" and the remote folder name is "remotehost:/dir2":

1. Login to first machine as 'root' user.

2. Create a local mount point to mount the remote folder.
    # mkdir /rmtmnt

3. Mount the Folder in remote machine using 'sshfs'
    # sshfs user@remotehost:/dir2  /rmtmnt

4. Run the 'diff' command
     # diff /dirl /rmtmnt -r --brief

5. After the execution, umount the remote filesystem using 'fusermount -u'.
     # fusermount -u /rmtmnt
    
Please note 'umount' command wouldn't work with sshfs.

2 comments:

  1. Having read this I believed it was extremely informative.

    I appreciate you finding the time and energy to put this information together.

    I once again find myself spending way too much time
    both reading and posting comments. But so what, it
    was still worthwhile!http://bit.ly/14DGx9C

    ReplyDelete
  2. Bluehost is ultimately the best web-hosting company with plans for any hosting needs.

    ReplyDelete