rsync command exclude option

Kaushal Shriyan kaushalshriyan at gmail.com
Wed Nov 26 13:01:48 GMT 2008


On Wed, Nov 26, 2008 at 5:28 PM, Michal Soltys <soltys at ziu.info> wrote:

> 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.
>

Thanks a Lot

I want only .sql files to be rsynced to the destination host.

when i do rsync -avz oldUnicelFiles hostB:/home/kaushal
--include-from=include.txt
it rsync all the files under oldUnicelFiles, I mean even .gz and .txt files
too.

~/oldUnicelFiles $ ls
01-07-2008_LOG.txt.gz  01-08-2008_LOG.txt  02-09-2008_LOG.txt.sql
~/oldUnicelFiles $

cat include.txt
#####################
/oldUnicelFiles/*.sql
#####################

am i missing something

Thanks and Regards

Kaushal
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the rsync mailing list