[CentOS] excluding directories in rsync

Indunil Jayasooriya indunil75 at gmail.com
Wed Oct 3 03:47:45 UTC 2007


This may work. If worked, Pls reply to the list by appending SOLVED to the
subject line. Then, Others can beniit.


rsync -avz --delete --exclude=**/stats --exclude=**/error
--exclude=**/files/pictures -e "ssh -i /root/rsync/mirror-rsync-key"
someuser at server1.example.com:/var/www/ /var/www/

(The --delete option means that files that have been deleted on
server1.example.com should also be deleted on mirror.example.com. The
--exclude option means that these files/directories should not be mirrored;
e.g. --exclude=**/error means "do not mirror /var/www/error". You can use
multiple --exclude options. I have listed these options as examples; you can
adjust the command to your needs. Have a look at

another URL to read,

http://www.howtoforge.com/mirroring_with_rsync_p2

GOOD LUCK

On 10/3/07, Ski Dawg <centos at skidawg.org> wrote:
>
> Hello Everyone,
>
> I am trying to exclude a directory (and all file and sub-directories
> under that directory) when using rsync.
>
> I have spent two days on google, but everything that I can find there
> involves excluding individual files, not an entire directory.
>
> I have tried the following commands, but in each case the remove_dir and
> all of its sub-directories and files area still sent to the remote
> server.
>
> 1) rsync --delete --compress --archive --rsh=ssh
> --exclude="**/remove_dir/**" /local/path/ $user@$host:remote/path
>
> 2) rsync --delete --compress --archive --rsh=ssh
> --exclude="\*\*/remove_dir/\*\*" /local/path/ $user@$host:remote/path
>
> 3) rsync --delete --compress --archive --rsh=ssh
> --exclude="/local/path/**/remove_dir/**" /local/path/
> $user@$host:remote/path
>
> 4) rsync --delete --compress --archive --rsh=ssh
> --exclude-from=/path/to/exclude_file /local/path/ $user@
> $host:remote/path
>
> and the /path/to/exclude_file contains:
> # don't include these files/dirs
> - **/remove_dir/**
>
> Any thoughts on the proper way to exclude an entire directory and its
> sub-directories and files when doing an rsync?
> --
> Doug
>
> Registered Linux User #285548 (http://counter.li.org)
> ----------------------------------------
> Random Thought:
> QOTD:
>         If it's too loud, you're too old.
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>



-- 
Thank you
Indunil Jayasooriya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.centos.org/pipermail/centos/attachments/20071003/6c585d4a/attachment.htm


More information about the CentOS mailing list