Thank you Johnsyweb and Alexandrin Rus @ https://stackoverflow.com/questions/9090817/copying-files-using-rsync-from-remote-server-to-local-machine for the initial information
rsync -chavzP --stats [email protected]:/path/to/copy /path/to/local/storage
rsync -chavzP -e "ssh -p $portNumber" [email protected]:/path/to/copy /local/path
Practical example from local machine with non standard ssh port, excluding a couple remote folders (relative paths to them):
rsync -chavzP --exclude 'dir1' --exclude 'dir2' -e "ssh -p $portNumber" [email protected]:/home/youraccount/public_html/website.com ~/Downloads/websitecom/
Switches explanation (Credit to https://explainshell.com/):
- -c: This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a "quick check" that (by default) checks if each file’s size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size.
- -h: Output numbers in a more human-readable format.
- -a: Archive. It is a quick way of saying you want recursion and want to preserve almost everything. Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.
- -v: Verbose
- -z: Compress. With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted -- something that is useful over a slow connection.
- -P: The -P option is equivalent to --partial --progress. Its purpose is to make it much easier to specify these two options for a long transfer that may be interrupted.
- --stats: This tells rsync to print a verbose set of statistics on the file transfer, allowing you to tell how effective rsync’s delta-transfer algorithm is for your data.
- -e: Alterntate remote shell program