I have such directories structure on server 1:
For example, if you only want to sync target/classes/
and target/lib/
to a remote system, do
rsync -vaH --delete --delete-excluded --include='classes/***' --include='lib/***' \
--exclude='*' target/ user@host:/deploy/path/
The important things to watch:
/
" from the end of the pathes, or you will get a copy into subdirectory.--include
, --exclude
counts./
" an include/exclude parameter is unneeded, they will automatically appended to the source directory (target/
in the example).--dry-run
flags, as the other answers say.--delete-excluded
will delete all content in the target directory, except the subdirectories we specifically included. It should be used wisely! On this reason, a --delete
is not enough, it does not deletes the excluded files on the remote side by default (every other, yes), it should be given beside the ordinary --delete
, again.