> ## Content Index
> Fetch the complete content index at: https://blog.alphavps.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Rsync over SSH: Secure Linux VPS File Transfers and Backups
- URL: https://blog.alphavps.com/rsync-over-ssh-secure-linux-vps-file-transfers-and-backups/
- Published: 2026-01-29T08:51:47.000Z
- Updated: 2026-09-08T15:18:09.000Z
- Author: Karim Buzdar
- Tags: Tutorials, Security, Backups & Storage

When managing a Linux VPS, secure and efficient file transfers are essential, especially for backups, migrations, and syncing large directories. Rsync is one of the safest and fastest ways to transfer files from server to server. It uses SSH encryption, while only synchronizing the changed portions of files. 

This guide will walk you through all the information you need: how rsync works, how you can transfer files, automate backups, and optimize performance.

## What Is Rsync Over SSH?

Rsync, a powerful tool for copying files and directories, synchronizes them between your local computer and a remote Linux VPS. When combined with SSH, rsync is fully encrypted. This means that your data will be secure during the transfer. It is ideal for:

- Backups of VPS data are secure
- Server-to-server migration
- File sync is automated every day
- Website or app deployments
- Remote directory duplication

## Rsync over SSH: Secure Linux VPS File Transfers and Backups

It is the most secure and efficient way to perform daily backups and synchronize directories on a Linux VPS. rsync is the fastest, safest, and most reliable way to operate servers. It only transfers modified blocks and encrypts all data using SSH. Rsync is a flexible and powerful solution for any environment, whether you are deploying code, backing up critical data, or migrating servers.

Check rsync installation:

```bash
rsync --version
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-d70ea6d0-da8c-4451-8312-8e1426f5bf8b.png)

If not installed on Ubuntu/Debian:

```bash
sudo apt install rsync -y
```

### Step 1: Basic Rsync Over SSH Command

The easiest rsync command over SSH:

```bash
rsync -avz -e ssh /source/path username@server-ip:/destination/path
```

**Explanation of each option:**

- \-a – Archive mode
- \-v-- Verbose output for progress indication
- \-z -- Compress data during transfer
- \-e SSH - Forces Rsync data to be sent through SSH
- /source/path: The folder or files you wish to transfer
- Remote VPS login: username@server-ip
- /destination/path: Where should data be saved on VPS

This is perfect for initial backups or one-time transfers.

### Step 2: Rsync from Local to Remote VPS

Uploading website files to the server is an example.

```bash
rsync -avz -e ssh ~/mywebsite/ root@123.45.67.89:/var/www/html/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-edf76a7e-01d6-4733-8956-38ea865015de.png)

What’s happening:

- Your local directory "/mywebsite/" is synced
- SSH authenticates securely
- The files are copied into /var/www/html/ of the server
- Only the changed files will be transferred

This tool is ideal for updating website content by developers.

### Step 3: Rsync from VPS to Local Machine (Download Backup)

You pull your Nginx configuration from the server and store it locally at \~/server-backups/nginx/.

```bash
rsync -avz -e ssh root@123.45.67.89:/etc/nginx/ ~/server-backups/nginx/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-d912570b-0ec0-40fa-b917-6a403dba0c69.png)

### Step 4: Rsync Between Two Remote VPS Servers

You can migrate data between two servers directly:

```bash
rsync -avz -e ssh root@server1:/var/www/ root@server2:/var/www/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-c378149a-cd13-45de-bbc4-38e29d15ea33.png)

**Explanation**:

- SSH login to server1 by Rsync
- Data transfer and reading
- Write directly to the server
- No need for local download

It is possible to move websites and apps quickly between VPS servers.

### Step 5: Enable Passwordless Rsync with SSH Keys (Recommended)

SSH keys can be used to automate Rsync, making it even more efficient.

Generate SSH key pair:

```bash
ssh-keygen -t ed25519
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-d25d2c17-f378-47df-8c28-b0464b7f07d4.png)

Copy key to VPS:

```bash
ssh-copy-id username@server-ip
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-ae7d1541-98ac-41a5-b82c-9359b981c429.png)

This makes rsync ideal for cron tasks and automated backups.

### Step 6: Automate Rsync Backups with Cron

Create a backup every day at midnight. Open cron:

```bash
crontab -e
```

Add:

```bash
0 0 * * * rsync -avz -e ssh /home/user/data/ root@123.45.67.89:/backup/data/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-0612cd39-47a9-4ce2-b21a-cf4aae98603c.png)

**Explanation**:

- \*\*0 0 \* \* \*\*\* → Runs every day at midnight
- The local /data/ directory is synced by Rsync
- VPS backups are stored in /backup/data/

It is easy to set up daily backups.

### Step 7: Use Rsync with Important Safety Flags

The powerful features of Rsync include:

**\--delete**

Deletes files on the destination that no longer exist on the source.

Example:

```bash
rsync -avz --delete /src/ user@server:/dest/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-4375b575-1749-4c31-869d-051d16655868.png)

**Use with caution:** This makes the destination an exact mirror.

**\--progress**

Shows live file-transfer progress:

```bash
rsync -avz --progress /src/ user@server:/dest/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-06c89438-5f45-4b38-be73-1c29f60a775e.png)

**\--exclude**

Skip unwanted files:

```bash
rsync -avz --exclude "*.log" /src/ user@server:/dest/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-e47cfc4e-62f6-4bc5-986b-2cdf5bd02c3f.png)

This keeps your backup clean.

### Step 8: Optimize Rsync Speed

Increase SSH transfer speed

```bash
rsync -avz -e "ssh -o Compression=no -T -c aes128-ctr" /src/ user@server:/dest/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-dfdb2a59-53a8-45cf-8cfb-7662fc584541.png)

**Explanation:**

- Aes128 is an SSH cipher that's fast
- Compression=no reduces CPU usage
- \-T disables TTY allocation

Great for large server migrations.

### Step 9: Verify Data Integrity After Rsync

You can verify the integrity of your files using:

```bash
rsync -avc /src/ user@server:/dest/
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-8d662d7f-ff0b-4512-a3b0-c796fd6c20bd.png)

**\-c** Compare file checksums, ensuring data integrity.

Used for:

- Production server migrations
- Large data transfers
- Database backups

## Conclusion

Rsync over SSH allows you to securely transfer and synchronize files between your local machine and a Linux VPS by combining rsync's fast, differential file-copying capability with encrypted SSH connections; you simply install rsync on both systems, then run a command like rsync -avz -e ssh /source/path user@server:/destination/path to sync data, where -a preserves file attributes, -v shows details, and -z compresses transfers, and you can also sync remote-to-local, server-to-server, automate backups with cron, and enable passwordless authentication using SSH keys, making rsync over SSH a powerful and secure solution for VPS backups, migrations, and routine file updates.

If you're planning to launch an online project and need a [**Storage VPS**](https://alphavps.com/storage-vps.html?ref=blog.alphavps.com), feel free to contact us. Our experts will help you choose a solution tailored to your needs and goals.