rsync selectively copy some file type using include exclude options

Written by
Date: 2012-12-31 15:54:32 00:00

If you need to sync only certain type of files, and not all the files between two computers, you can take advantage of the include and exclude options of rsync to copy only those types of files

Say you want to copy only php files from one server to another, you can use this command.

rsync -av --include='*/' --include='*.php' --exclude='*' \[source\] \[destination\]

Now if you want to copy only css and js files, use this command:

rsync -av --include='*/' --include='*.js' --include'*.css' --exclude='*' \[source\] \[destination\]

Replace [source] and [destination] with your own data.