How to exclude MULTIPLE directories in a rsync command ?

This is a discussion on How to exclude MULTIPLE directories in a rsync command ? within the Linux Networking forums, part of the Linux Forums category; As I learned from the man page of rsync I can exclude a certain directory (trees) by using the --exclude ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 6 Days Ago
Matthew Lincoln
 
Posts: n/a
Default How to exclude MULTIPLE directories in a rsync command ?

As I learned from the man page of rsync I can exclude a certain directory (trees)
by using the --exclude option like in

rsync .... --exclude=/proc ....

But how do I exclude multiple directory (trees) at once in such a rsync command?
The following does not work:

rsync .... --exclude=/proc||/var||/dummy ....

Same with "&&" instead of "||"

Matthew
Reply With Quote
  #2 (permalink)  
Old 6 Days Ago
Wayne
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

Matthew Lincoln wrote:
> As I learned from the man page of rsync I can exclude a certain directory (trees)
> by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a rsync command?
> The following does not work:
>
> rsync .... --exclude=/proc||/var||/dummy ....
>
> Same with "&&" instead of "||"
>
> Matthew


Use multiple --exclude=dir arguments.

-Wayne
Reply With Quote
  #3 (permalink)  
Old 6 Days Ago
Nico Kadel-Garcia
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

On 7 May, 06:57, kmlincoln...@hotmail.com (Matthew Lincoln) wrote:
> As I learned from the man page of rsync I can exclude a certain directory (trees)
> by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a rsync command?
> The following does not work:
>
> rsync .... --exclude=/proc||/var||/dummy ....
>
> Same with "&&" instead of "||"
>
> Matthew


Try 'rsync --exclude=/proc --exclude=/var --exclude=/dummy
Reply With Quote
  #4 (permalink)  
Old 6 Days Ago
Dave B
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

On Wednesday 7 May 2008 07:57, Matthew Lincoln wrote:

> As I learned from the man page of rsync I can exclude a certain directory
> (trees) by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a rsync
> command? The following does not work:
>
> rsync .... --exclude=/proc||/var||/dummy ....
>
> Same with "&&" instead of "||"


You can repeat --exclude many times to specify multiple exclusions.
Alternatively, you can use the --exclude-from option and put the names to be
excluded in a file, one per line. Read man rsync for the details.

--
D.
Reply With Quote
  #5 (permalink)  
Old 6 Days Ago
PM
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

Matthew Lincoln wrote:
> As I learned from the man page of rsync I can exclude a certain directory (trees)
> by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a rsync command?
> The following does not work:
>
> rsync .... --exclude=/proc||/var||/dummy ....
>


rsync .... --exclude=/proc --exclude=/var --exclude=/dummy
Reply With Quote
  #6 (permalink)  
Old 6 Days Ago
Nicolas KOWALSKI
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

On Wed, 7 May 2008, Matthew Lincoln wrote:

> As I learned from the man page of rsync I can exclude a certain
> directory (trees) by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a
> rsync command?


Use multiple "--exclude /path/to/unwanted/directory/" options.

rsync ... \
--exclude /proc/ \
--exclude /var/ \
--exclude /dummy/ \
...

This works well.

--
Nicolas
Reply With Quote
  #7 (permalink)  
Old 6 Days Ago
Chris Davies
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

In comp.os.linux.misc Matthew Lincoln <kmlincoln100@hotmail.com> wrote:
> As I learned from the man page of rsync I can exclude a certain
> directory (trees) by using the --exclude option like in
> rsync .... --exclude=/proc ....


> But how do I exclude multiple directory (trees) at once in such a
> rsync command?


You get good marks for reading the man page. (You'd be amazed how many
people don't even bother to try...) I think the bit you missed is this:

Note also that the --filter, --include, and --exclude options take one
rule/pattern each. To add multiple ones, you can repeat the options
on the command-line [...]

Personally, I don't find the interaction between the --include/--exclude
directives particularly intuitive. If it's simply a case of "exclude
this and that", then you should be fine. However, as soon as I wanted to
"include this but exclude that", I ended up taking some of the working
examples (from the man page) and tweaking them until I got something
that worked.

Chris
Reply With Quote
  #8 (permalink)  
Old 6 Days Ago
Kevin the Drummer
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

Matthew Lincoln <kmlincoln100@hotmail.com> wrote:

> As I learned from the man page of rsync I can exclude a certain
> directory (trees) by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such
> a rsync command? The following does not work:


Use multiple '--exclude='

rsync .... --exclude=/proc --exclude=/net --exclude=/tmp

G'luck...

--
PLEASE post a SUMMARY of the answer(s) to your question(s)!
Show Windows & Gates to the exit door.
Unless otherwise noted, the statements herein reflect my personal
opinions and not those of any organization with which I may be affiliated.
Reply With Quote
  #9 (permalink)  
Old 6 Days Ago
Bruce Esquibel
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

In comp.security.ssh Matthew Lincoln <kmlincoln100@hotmail.com> wrote:

> As I learned from the man page of rsync I can exclude a certain directory (trees)
> by using the --exclude option like in


> rsync .... --exclude=/proc ....


> But how do I exclude multiple directory (trees) at once in such a rsync command?
> The following does not work:



Check the man page for --exclude-from=

You just need to set up a simple text file will all the excludes and call
rsync with the --exclude-from= to read the file in.

-bruce
bje@ripco.com
Reply With Quote
  #10 (permalink)  
Old 6 Days Ago
loki harfagr
 
Posts: n/a
Default Re: How to exclude MULTIPLE directories in a rsync command ?

On Wed, 07 May 2008 05:57:09 +0000, Matthew Lincoln wrote:

> As I learned from the man page of rsync I can exclude a certain
> directory (trees) by using the --exclude option like in
>
> rsync .... --exclude=/proc ....
>
> But how do I exclude multiple directory (trees) at once in such a rsync
> command? The following does not work:
>
> rsync .... --exclude=/proc||/var||/dummy ....
>
> Same with "&&" instead of "||"


you may use a file with: --exclude-from=FILE

((Linux manpage 2-79):
This option is related to the --exclude option, but it specifies a FILE that contains exclude patterns
(one per line). Blank lines in the file and lines starting with ';' or '#' are ignored. If FILE is -,
the list will be read from standard input.
)

for instance, I used it this way in a quick&dirty backup script
-------
EXCLUDED="- junk/
- .thumbnails/
- .googleearth/
- .macromedia/
- .kde/
"
....
echo "${EXCLUDED}" | rsync -vax --delete /home --cvs-exclude --exclude-from=- --delete-excluded ${BKUPDIR}
-------
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:18 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0