Upload/Download File

Use below commands to upload or download a file to or from a remote server with ability to resume the download in case of network connection loss.

$ rsync -P --rsh=ssh user@DomainOrIP:~/file.zip .
$ rsync -P --rsh=ssh file.zip user@DomainOrIP:~/file.zip

$ rsync -Pav --rsh=ssh user@DomainOrIP:/path/to/source/ ./destination
Downloads files inside source direcotory to destination directory.

$ rsync -Pav --rsh=ssh user@DomainOrIP:/path/to/source ./destination
Downloads whole source direcotory in to destination directory.

Upload Files to Directory

Use below command to replace files and folders of a remote directory with files and folders of current directory.
It excludes the hidden files/directories in the current directory to be copied over.

$ rsync -arvh --delete --chown=user:group --force --exclude=".*" ./* user@DomainOrIP:/path/to/the/destination/folder
Replace user, group and DomainOrIP with its appropriate values.

Options

-a Archive (preserves modification times, groups, owners and permissions and symbolic links etc.)
-n Dry run. Shows output withing physically transfer any files.
-v Verbose output
-P Partial or progress. Suitable for long transfers which can be interrupted