Tagged: Laughing Squid RSS Toggle Comment Threads | Keyboard Shortcuts

  • zuhaib 10:42 pm on February 14, 2011 Permalink | Reply
    Tags: Bash, Laughing Squid, Plesk, Server Fault   

    Using diff (or rsync) to compare folders over SSH on two different servers 

    So I wanted to find a quick code that will allow me to a diff over two folders as I want to be sure all files get transfered as we are using Plesk migrator to move domains from one server to another. Found a Serverfault post titled How do diff over ssh? but most of the suggestions are for files and not folders and none that work recursively. Well using this answer from Server Fault and some man pages I have the following

    diff <(ssh server1 'sudo ls -1aR /var/www/vhosts/domain.com') <(ssh server2 'sudo ls -1aR /var/www/vhosts/domain.com')
    

    Update:
    So a lot of people in the ServerFault page I linked to mentioned rync with the –dry-run flag. I did not look in to this much but just as I posted this blog the first @reply i got on twitter was from @EvanHoffman asking if I had looked at using rsync. Ok so I thought I should revisited the problem and using rsync and I got the follow:

    rsync --dry-run -rvce "ssh -p port#" user@server1:/var/www/vhosts/ /var/www/vhosts/domain.com/
    

    (I have not tested the rsync solution with a live box but from testing on my local system I assume this would work)
    One of the limitation of this you need to be on one of the two servers vs the solutions using diff is something you do on your computer that can SSH to both systems.

     
    • Stainless 9:38 am on January 12, 2012 Permalink

      I think the first command works, the second I tried and it works.But there is no example on the net that I can find that diffs a local directory and a remote directory .So I wrote a script and it just compare the file count, you can change it to do the ` du ` and get the file size.:

      #!/bin/bash

      LOCALFOLDER=/var/www/tee

      REMOTEFOLDER=$(ssh root@111.111.111.1 ‘ls -lA /hfs/tee’| grep -E ‘^total’ | cut -d ” ” -f 2 > remotessh.txt)

      COMMAND=$(ls -lA $LOCALFOLDER | grep -E ‘^total’ | cut -d ” ” -f 2 > localssh.txt)

      REM=$(cat remotessh.txt)
      LOCAL=$(cat localssh.txt)

      echo $LOCAL
      echo $REM

      if [ $REM -eq $LOCAL ]
      then
      echo Directories are the same

      else

      echo Directories are differnt

      fi

  • zuhaib 10:44 pm on October 3, 2010 Permalink | Reply
    Tags: , Laughing Squid,   

    Laughing Squid 15th Anniversary New York Trip Photos 

     
  • zuhaib 4:31 pm on July 21, 2010 Permalink | Reply
    Tags: , Laughing Squid,   

    Laughing Squid Trip to New York 

     
  • zuhaib 8:52 am on June 28, 2010 Permalink | Reply
    Tags: Cruiser, Laughing Squid, Russian, Ship   

    Russian Cruise Missile Ship
    Great Backdrop for a Laughing Squid Party from last Thursday. http://en.wikipedia.org/wiki/Russian_cruiser_Varyag_(1983)

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel