Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to exclude MULTIPLE directories in a rsync command ?

Reply
Thread Tools Display Modes

How to exclude MULTIPLE directories in a rsync command ?

 
 
Matthew Lincoln
Guest
Posts: n/a

 
      05-07-2008, 05:57 AM
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
 
 
 
 
Wayne
Guest
Posts: n/a

 
      05-07-2008, 06:41 AM
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
 
Nico Kadel-Garcia
Guest
Posts: n/a

 
      05-07-2008, 06:46 AM
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
 
Dave B
Guest
Posts: n/a

 
      05-07-2008, 07:02 AM
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
 
PM
Guest
Posts: n/a

 
      05-07-2008, 07:49 AM
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
 
Nicolas KOWALSKI
Guest
Posts: n/a

 
      05-07-2008, 08:34 AM
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
 
Chris Davies
Guest
Posts: n/a

 
      05-07-2008, 08:42 AM
In comp.os.linux.misc Matthew Lincoln <(E-Mail Removed)> 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
 
Kevin the Drummer
Guest
Posts: n/a

 
      05-07-2008, 03:09 PM
Matthew Lincoln <(E-Mail Removed)> 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
 
Bruce Esquibel
Guest
Posts: n/a

 
      05-07-2008, 04:08 PM
In comp.security.ssh Matthew Lincoln <(E-Mail Removed)> 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
(E-Mail Removed)
 
Reply With Quote
 
loki harfagr
Guest
Posts: n/a

 
      05-07-2008, 05:45 PM
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

« DNS problem | 2057 »
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get log file for rsync operation? Does rsync also delete remote files? Goran Ivanic Linux Networking 9 05-05-2008 04:58 PM
How to let rsync only copy over the directories on destination side? linq936@hotmail.com Linux Networking 1 06-08-2007 10:34 AM
Unable to download deep files and directories recursively with mget -R command... ANTant@zimage.com Linux Networking 9 02-21-2005 07:35 AM
"Exclude directories in roaming profile" Lennart Svenssson Windows Networking 0 11-17-2004 01:55 PM
Problem Adding Multiple MAC addresses with the command line Hans Wireless Internet 0 07-07-2003 07:11 AM



1 2 3 4 5 6 7 8 9 10 11