[CentOS] OT: Rsync question

Jeff Larsen jlar310 at gmail.com
Sun Dec 9 00:54:56 UTC 2007


On Dec 8, 2007 6:21 PM, Steven Vishoot <sir_funzone at yahoo.com> wrote:
> So in general is there a way i can do multiple
> directories in one command or am i left with doing
> them each individual as in rsync -av server:/dir1/
> /dir1/
> and repeat for the rest of directories. or does
> someone know of a better way. my final goal is to have
> a cronjob do this.

Look at the --include-from and --exclude-from options in the rsync man
page and then read the section further down that explains the format
for include/exclude files. Generally, you can use the --exclude-from
option to set up both includes and excludes by using + and - notation
in your pattern file.

So your pattern file might be something like:

+ /dir1
+ /dir2
+ /dir3
- **

You'll have to play with it some. I use this technique to do a
selective rsync of the CentOS repository for local yum access.

Although, there's no reason the ' for i in /dir1 /dir2 /dir3'
shouldn't work. Start debugging your script without the loop, just
rsync /dir1 and get that working, then add more.

Jeff



More information about the CentOS mailing list