Exclude Directory From Rsync

Home » CentOS » Exclude Directory From Rsync
CentOS 2 Comments

hey guys,

I’m trying to do an rsync of the entire /var directory, but exclude just the /var/www directory.

So far I’ve tried these approaches:

rsync -avzp –exclude-from=/var/www /var/ /mnt/var/

rsync -avzp –exclude=/var/www /var/ /mnt/var/

But neither has worked. Can I get a suggestion on how to get this to happen?

Thanks, Tim

2 thoughts on - Exclude Directory From Rsync

  • –exclude-from takes a filename as an argument. That filename is expected to contain a list of patterns to exclude.

    If your exclude pattern begins with ‘/’, then it matches a filename immediately within the transfer root. So in this case, “/var/var/www”.

    Read the “FILTER RULES” and “INCLUDE/EXCLUDE PATTERN RULES” sections of the manual.

    Try:

    rsync -avzp –exclude=/www /var/ /mnt/var/

  • Hey guys,

    Thanks for your input! Both examples you gave worked, and I’ll do some reading on the suggested subjects!! Just a heads up that it worked. I
    appreciate the clarification!

    Thanks, Tim