Diff on remote servers file systems


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Diff on remote servers file systems
# 1  
Old 03-05-2014
Diff on remote servers file systems

Iam trying to compare two file systems on two hosts basically to check them to be in sync

I dont have rsync so trying to use diff

Let me know how to do it....

Thanks
# 2  
Old 03-05-2014
generate a listing of each filesytem (find -xdev <file-system> -exec ls or something), sort and diff them...try putting something together.
# 3  
Old 06-02-2014
rsync would really help you with this, but I suppose if you wanted to do a diff, you could run the command

$ diff -rupN <filesystem1> <filesystem2>

which you could create a patch from the diff output, and you could "patch" filesystem1, to make them sync. hope this helps.
# 4  
Old 06-02-2014
Here's a really crude thing I threw together just now that worked for me. Some variation on this, which just gets a list of files and checksums with "ssh", might help.

Code:
#!/bin/bash

for hh in HOST1 HOST2
do
    ssh $hh 'cd PATH-TO-DIRECTORY || exit; find . -type f -print | while read path; do echo "$path $(sum $path)"; done'
done \
| sort \
| uniq -c \
| gawk '\

    { fr[$2] = $1; }

    END \
    {
    for( path in fr )
      if(fr[path] == 2) printf "Same %s\n", path
      else printf "Diff %s\n", path
    }'

Replace HOST1 and HOST2 with hostnames that will work on an "ssh" command. Meaning, short names if that works or fully qualified domain names. It just needs to get you to the server the script doesn't use that info afterwards.

And replace PATH-TO-DIRECTORY with the top of the directory tree you want to compare.

I tried just doing "-exec sum {} \;" in the "find" but it doesn't print the filename on the systems I'm using. That's why there's a shell script consuming the output from find and running "sum".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with create multiple directories under diff file systems

Hi, Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl. ../ORCL_data01/oradata/orcl/data. ../ORCL_data01/oradata/orcl/redo. Script :- ========= for dir in `ls -d... (8 Replies)
Discussion started by: Linux6.5
8 Replies

2. Shell Programming and Scripting

Replacing value in a file on all remote systems.

Hello All, I want to replace a value of a string in a file on all the remote systems. The file is /opt/adapter/Adapter/snmp/conf/snmpd.conf and the parameter to be replaces if "rocommunity" for which current value is "public" and wish to change it to "sp1der". i did trying it through sed, but... (4 Replies)
Discussion started by: Siddheshk
4 Replies

3. Shell Programming and Scripting

Append Text To Remote Servers File Via SSH

Gentleman & Ladies, Please make me feel like and novice and explain why this is not working? I am attempting to ssh to a remote server via ssh and keys. I want to inject a file on the remote server with text. I am not achieving this. I would like to echo/inject the text on the remote... (1 Reply)
Discussion started by: abacus
1 Replies

4. Shell Programming and Scripting

Copy a file on remote servers

Hey Unix Gurus, I'm having trouble in copying a file on 5 different servers, first how can you do it locally (i.e without the need to ssh to the server you want to copy the file) and if you need to ssh how do u run a command within that server. Please see my code below(it doesn't work somehow).... (10 Replies)
Discussion started by: sexyTrojan
10 Replies

5. IP Networking

how to cp between servers on diff network

Hi, how can i sftp or scp between 2 servers, when only i am able to ping to them. they are on different network 10.130.170.31 -- server 1 10.130.230.141 -- server 2 i need to transfer data files from 1 to 2. need your suggestions or help on these. Regards saha (4 Replies)
Discussion started by: saha
4 Replies

6. Shell Programming and Scripting

update a common file in different/remote servers

Dear All, I need to update a common file (ie. same path and same filename) but located in different servers. (ie. remotely located ~ able to ssh from my server). Can someone help me how to go ahead with this? (Since I'm manually editing that file in 20 servers :() (1 Reply)
Discussion started by: techychap
1 Replies

7. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

8. Shell Programming and Scripting

Find match in two diff file - local srv and remote server

Perl Guru.... I need to compare two diff file (file1.abc will locate in current server and file2.abc will locate in remote server), basically the script will look for match in both file and only will send out email if there is no match and also give me list of unmatch and dups as well. So... (0 Replies)
Discussion started by: amir07
0 Replies

9. Shell Programming and Scripting

restore mysql dump file in many remote servers?

Hi all, I want to restore DB file in many mysql servers, i already using script for sending the dumpfile in all servers, but it's just annoying if i have to restore the dumpfile in all servers, i want just execute 1 script, and will restore in all remote mysql servers. I make script but not... (2 Replies)
Discussion started by: blesets
2 Replies

10. UNIX for Advanced & Expert Users

remote file copy across 2 systems (AIX and SCO)

Hello, Pls i need to copy some data from AIX Unix 4.3 to a SCO Openserve 5.0.5 using rcp command. But i keep on having permission error. WHAT IS THE SOLTION OR WHAT COMMAND CAN I USE AGAIN (4 Replies)
Discussion started by: aji
4 Replies
Login or Register to Ask a Question