RSync is a powerful tool that enables fast incremental file transfer and is widely used for mirroring and backing up data. You can secure this data further by transferring it over SSH (Secure Shell), which provides robust authentication and encrypted data communications.
Here’s the basic syntax of using RSync over SSH:
```
rsync -avz -e ssh source-directory user@remote-server:destination-directory
```
Here `-e ssh` tells rsync to use SSH as the remote shell, `source-directory` is the directory you want to transfer, `user` is the username on the remote server, `remote-server` is the domain or IP address of the remote server, and `destination-directory` is the directory where you want to save the files.
In this command, the options `-avz` stand for:
-Archive (`-a`), which preserves the directory structure and file metadata.
-Verbose (`-v`), which gives detailed output.
-Compress (`-z`), which reduces the data size over the network.
Consider the scenario of transferring a directory called `Project` from a local system to a remote server with IP address `12.34.56.78`. The username on the remote server is `alex`. To transfer the `Project` directory to a directory called `/home/alex/Work`, the command would be:
```
rsync -avz -e ssh Project alex@12.34.56.78:/home/alex/Work
```
For copying individual files, the syntax is more straightforward:
```
rsync -avz -e ssh source-file user@remote-server:destination-file
```
To secure the data during transfer, it’s crucial to enable SSH. Implementing rsync with SSH not only provides secure data transfer by encrypting the data but also leverages efficient data handling of rsync. For bulk data transfer and frequent updates between systems, rsync over SSH is deemed to be an optimum solution.
Example:
Suppose you need to transfer `test.txt` file from the local system to `/home/alex` directory on the remote server. The command will be:
```
rsync -avz -e ssh test.txt alex@12.34.56.78:/home/alex
```
Please ensure that you install `rsync` on both the local and remote machines. If `rsync` is not installed, you can easily install it using package managers like `apt` for Ubuntu/Debian:
```
sudo apt-get install rsync
```
Or `yum` for CentOS/RHEL:
```
sudo yum install rsync
```
This information was gathered from various tech sources such as DigitalOcean ([source](https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps)), Linuxize ([source](https://linuxize.com/post/how-to-use-rsync-for-local-and-remote-data-transfer-and-synchronization/)), and Tecmint ([source](https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/)).