Link to home
Start Free TrialLog in
Avatar of wademi
wademi

asked on

Linux Help - Cshell - Rsync

I Need help to write a CShell script that coiesy subdirectories in FolderA  to  FolderB using CShell + Rsync on a CentOsServer:

Here is the scenario:

•      I have 2 remote servers ServerA and SeverB.
•      I mounted 2 Directories from the remote servers to my local CentOsServer.  Mount details: ServerA( Folder1), and ServerB (Folder2) .
•      The Cshell script should copy folders from ServerA( Folder1) to ServerB (Folder2).
•      The script should check to see if the folder exsist in ServerB (Folder2). If the folder does not exsist copy the folder including all files

Can someone please help me with the Cshell script to do this?

Thanks
Avatar of xterm
xterm

You actually don't need a script for this, it's very simple.  The -u option to sync tells it to run in update mode, which will not overwrite a folder that already exists, however, it will copy files inside a folder to the matching folder on the other end if the files themselves do not exist.  Let me know if there's a different behavior you would like to achieve.  If not, then simply do (where Folder1 is the top directory where you mounted ServerA, and Folder2 is the top directory where you mounted ServerB):
rsync -avu Folder1 Folder2

Open in new window

Sorry one small error.  Folder1 needs a trailing / which means, everything INSIDE Folder1 gets synced to the inside of Folder2.  So:
rsync -avu Folder1/ Folder2

Open in new window

Avatar of wademi

ASKER

Hi xterm:. That worked but how would I view my rsync log
ASKER CERTIFIED SOLUTION
Avatar of xterm
xterm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial