开发者

rsync filtering

开发者 https://www.devze.com 2023-02-02 09:24 出处:网络
I use an rsync command to sync two directories remote >local the command is (used in python script) os.system(\'rsync --verbose --progress --stats --recursive\\

I use an rsync command to sync two directories remote >local

the command is (used in python script)

os.system('rsync --verbose --progress --stats --recursive\
          --copy-links --times --include="*/" --include="*good_name*.good_ext*"\
          --exclude-from "/myhome/mydir/src/rsync.exclude"\
          %s %s'%(remotepath,localpath))

I want to exclude certain directories that has the same files that I also want to include.

I want to include recursively

any_dir_name/any_file_name.good

but I want to exclude any and all files that are in

bad_dir_name/

I used --exclude-from and here is my exclude from file

*
/*.bad_dir_name/

Unfortunately it doesn't work. I suspect it may have something to do with --include="*/" but if I remove it开发者_开发知识库 the command doesn't sync any files at all.


I got it. I used -vv to find according to which rule the directory was showing up in the sync list and since rsync supports regular expressions, I changed my include statement from "*/" to

--include="*[^.bad_dir_name]/"

and all works fine now.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号