• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

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
0
wademi
Asked:
wademi
  • 3
1 Solution
 
xtermCommented:
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

0
 
xtermCommented:
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

0
 
wademiAuthor Commented:
Hi xterm:. That worked but how would I view my rsync log
0
 
xtermCommented:
You would need to tell it to keep a log file
rsync -avu --log-file=/path/to/mylog.txt Folder1/ Folder2

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now