View Single Post

  #10 (permalink)  
Old 05-07-2008
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