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

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 @EvanHoffmanasking 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.

reference: http://zuhaiblog.com/2011/02/14/using-diff-to-compare-folders-over-ssh-on-two-different-servers/

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s