LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   exclude hidden files from rsync (https://www.linuxquestions.org/questions/linux-newbie-8/exclude-hidden-files-from-rsync-4175549255/)

rayalab 07-29-2015 07:21 AM

exclude hidden files from rsync
 
Hi,

I am using --exclude=".DAV" to exclude .DAV folders from rsync jobs.
But .DAV folder is also copying in target path.

This is my job when I do : ps -ef | grep rsync

www 2188 1614 0 12:07 pts/4 00:00:00 /local/rsync --exclude=".DAV" --rsync-path=/local/rsync -vt --stats --progress --compress -e /usr/bin/ssh -x -p 22 --partial-dir=/local/partial --block-size=5000 --temp-dir=/local/inbound --timeout=3600 /local/myFiles/.DAV/ignore.zip www@www.dev.com:"/local/myFiles/.DAV/ignore.zip"

Can you please tell me what I am wrong here? why .DAV hidden folder is not excluded.

PS: my rsync command is created from java which will check for every 15 mins for new files. If it finds any new files, then creates a rsync job.



Thanks

HMW 07-29-2015 09:16 AM

Hi!

rsync's man page says:
Code:

      --exclude=PATTERN
              This option is a simplified form of the --filter option
              that defaults to an exclude rule and does not allow the
              full rule-parsing syntax of normal filter rules.

              See the FILTER RULES section for  detailed  information
              on this option.

My guess is that is the reason you fail to exclude the .DAV files/directories.

Hint:
Code:

--exclude='*.old'
Best regards,
HMW

Edit: Wait a minute! Maybe I misunderstood, if you simply want to exclude a SINGLE DIRECTORY, you can give the pathname to --exclude, something like this:
Code:

$ rsync -avz --exclude 'local/myFiles/.DAV' source/ destination/

rknichols 07-29-2015 11:03 AM

It is difficult to exclude something that you specifically asked to be included. Your command line argument "/local/myFiles/.DAV/ignore.zip" happens to lie within the excluded ".DAV" directory, but rsync never actually processes that directory.

rayalab 08-03-2015 02:12 AM

@HMW

Thanks for your reply.
in my case, I am not excluding only one particular file. .DAV folder can be anywhere. I have to exclude all .DAV folders.

@rknichols

Yes You are correct. my Java already initiated rsync job for the file from .DAV folder. In this case rsync cannot do anything even I have used exclude command. Now I understood.
I stopped creating rsync jobs in java if source path contains .DAV.
now it is working.

Thanks.


All times are GMT -5. The time now is 11:43 AM.