I am using rsyn to copy a folder from source to desination
I am able to use exclude successfully
$ rsync -av --exclude='*/deploy/scb_pdm/*' --exclude='*/logs/*' $COPY_SRC_DIR $COPY_DEST_DIR
server-4.5.0/conf/wrapper.conf server-4.5.0/deploy/ server-4.5.0/deploy/scb_pdm/ server-4.5.0/deploy/scb_pdm/director.properties server-4.5.0/deploy/scb_pdm/ocollate_static.madconfig server-4.5.0/lib/ server-4.5.0/lib/blue-marble-4.5.0.201511121524.jar
Now I am stuck, How can I exclude only
server-4.5.0/deploy/scb_pdm/ocollate_static.madconfig
I'll start with the generic usage of rsync to exclude the directory.
In order to achieve that you need to use --exclude
flag.
rsync -arv --exclude cache/ your_src_dir/ your_dest_dir/
to your case, this will exclude the specific file that is ocollate_static.madconfig
.
rsync -arv --exclude='*/deploy/scb_pdm/ocollate_static.madconfig*' --exclude='*/logs/*' $COPY_SRC_DIR $COPY_DEST_DIR
You can think of using another flag that is
--delete-excluded also delete excluded files from dest dirs
Another option, excluding multiple files and dirs at the same time.
$ rsync -avz --exclude your_file1.txt --exclude dir3/file4.txt source/ destination/
For detail information about using exclude in rsync.