Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync --include option does not exclude other files

Tags:

bash

rsync

trying to rsync files of certain extension(*.sh), but the bash script below still transfer all the files, why?

 from=/home/xxx rsync -zvr --include="*.sh" $from/*  root@$host:/home/tmp/ 
like image 664
user121196 Avatar asked Feb 01 '13 22:02

user121196


People also ask

How do I ignore files in rsync?

Exclude Files and Directories from a List. When you need to exclude a large number of different files and directories, you can use the rsync --exclude-from flag. To do so, create a text file with the name of the files and directories you want to exclude. Then, pass the name of the file to the --exlude-from option.

Does rsync Skip existing files?

Rsync with --ignore-existing-files: We can also skip the already existing files on the destination. This can generally be used when we are performing backups using the –link-dest option, while continuing a backup run that got interrupted. So any files that do not exist on the destination will be copied over.

What should I exclude from rsync?

The --exclude-from rsync option allows us to specify a file that contains a list of directories to be excluded. The file should be plaintext, so a simple . txt file will do. List one directory per line as you're compiling the list of directories that you want to exclude.


1 Answers

You need to add a --exclude all and it has to come after the --include

rsync -zvr --include="*.sh" --exclude="*" $from/*  root@$host:/home/tmp/ 
like image 162
JohnQ Avatar answered Oct 01 '22 11:10

JohnQ