-2

How to use "rsync" to copy directories and files (except certain types) to destination ? following are the file types to be exempted or not to be synced; *.odb, *.a3db

2 Answers 2

1

You can use the rsync filter feature. For example use the following command:

rsync -uva --filter="- *.odb" --filter="- *.a3db" /source-path/ /destination-path/
1

Use a couple of exclusion patterns:

rsync -av --exclude='*.odb' --exclude='*.a3db' source/ target/

Example:

$ ls source
file-1.a3db  file-2.odb   file-4.a3db  file-5.odb   file-7.a3db  file-8.odb
file-1.c     file-2.txt   file-4.c     file-5.txt   file-7.c     file-8.txt
file-1.odb   file-3.a3db  file-4.odb   file-6.a3db  file-7.odb   file-9.a3db
file-1.txt   file-3.c     file-4.txt   file-6.c     file-7.txt   file-9.c
file-2.a3db  file-3.odb   file-5.a3db  file-6.odb   file-8.a3db  file-9.odb
file-2.c     file-3.txt   file-5.c     file-6.txt   file-8.c     file-9.txt

Using -v twice, we get an indication of what's included and excluded:

$ rsync -avv --exclude='*.odb' --exclude='*.a3db' source/ target/
sending incremental file list
[sender] hiding file file-1.odb because of pattern *.odb
[sender] hiding file file-1.a3db because of pattern *.a3db
[sender] hiding file file-2.odb because of pattern *.odb
[sender] hiding file file-2.a3db because of pattern *.a3db
[sender] hiding file file-3.odb because of pattern *.odb
[sender] hiding file file-3.a3db because of pattern *.a3db
[sender] hiding file file-4.odb because of pattern *.odb
[sender] hiding file file-4.a3db because of pattern *.a3db
[sender] hiding file file-5.odb because of pattern *.odb
[sender] hiding file file-5.a3db because of pattern *.a3db
[sender] hiding file file-6.odb because of pattern *.odb
[sender] hiding file file-6.a3db because of pattern *.a3db
[sender] hiding file file-7.odb because of pattern *.odb
[sender] hiding file file-7.a3db because of pattern *.a3db
[sender] hiding file file-8.odb because of pattern *.odb
[sender] hiding file file-8.a3db because of pattern *.a3db
[sender] hiding file file-9.odb because of pattern *.odb
[sender] hiding file file-9.a3db because of pattern *.a3db
delta-transmission disabled for local transfer or --whole-file

(rest of output cut)

$ ls target
file-1.c   file-2.txt file-4.c   file-5.txt file-7.c   file-8.txt
file-1.txt file-3.c   file-4.txt file-6.c   file-7.txt file-9.c
file-2.c   file-3.txt file-5.c   file-6.txt file-8.c   file-9.txt

This also works even if the files are located in subdirectories under source.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .