Ubuntu - RSync - Copy data encrypted and exclude folders

rsync -av --exclude dir2 --exclude dir2 -n user@server:/var/www/path/to/somewhere .

This transfers recursively all files from the directory /var/www/path/to/somewhere on the machine server into the local directory on the local machine.

The files are transferred in “archive” mode, which ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer.

With --exclude directories which should not be copied can be skipped and -n tells rsync to run in the dry mode which simulates the operations which would take place.