rsync command exclude option

Michal Soltys soltys at ziu.info
Wed Nov 26 11:58:21 GMT 2008


Kaushal Shriyan wrote:
> Hi
> 
> I do rsync -avz oldUnicelFiles hostB:/home/kaushal 
> --exclude-from=exclude.txt
> but it rsynced  the excluded files too
> 
> my exclude.txt file contains
> ####################
> /home/kaushal/oldUnicelFiles/*.gz
> /home/kaushal/oldUnicelFiles/*.txt
> ####################
> 
> Any ideas as what am i doing wrong
> 

 From rsync perspective, root of file transfers in your case would be 
/home/kaushal , not / . So ...

/oldUnicelFiles/*.gz
/oldUnicelFiles/*.txt

... should do the thing.

If you used 'oldUnicelFiles/' instead of 'oldUnicelFiles' in rsync 
invocation, the root would be /home/kaushal/oldUnicelFiles/ .



A note of warning if you plan on doing deletions in the future:

rsync -avz --del oldUnicelFiles hostB:/home/kaushal

... would remove all files not existing on sending side, in 
hostB:/home/kaushal/oldUnicelFiles/

...but:

rsync -avz --del oldUnicelFiles/ hostB:/home/kaushal

...would do the same in hostB:/home/kaushal/

Both of the above would also protect already existing files on the 
receiving side, that match patterns in exclude.txt .


Be sure to read carefully rsync's man.


More information about the rsync mailing list