Hostxpeed
Login Get Started →
Getting Started

How to Transfer Files Using Rsync

6 min read
24 views
Jun 12, 2026

Prerequisites

Before using rsync, make sure you have:

  • SSH access to your VPS
  • Rsync installed on both local and remote machines
  • Your server IP address and username

💡 Rsync only transfers changed parts of files, making it much faster than SCP for repeated transfers and backups.

Step 1: Install Rsync

On Ubuntu/Debian (local and server):

apt install rsync -y

On macOS (local):

brew install rsync

On Windows (using WSL or Git Bash):

# Already included in Git Bash, WSL, or Cygwin

Basic Syntax

rsync [options] source destination

Method 1: Copy File from Local to VPS

rsync -avz /local/path/file.txt hxroot@YOUR_SERVER_IP:/remote/path/

Example:

rsync -avz backup.zip hxroot@148.113.173.106:/root/

Method 2: Copy Directory from Local to VPS

rsync -avz /local/folder/ hxroot@YOUR_SERVER_IP:/remote/folder/

Note the trailing slash:

  • /local/folder/ - Copies contents of folder
  • /local/folder - Copies folder itself

Method 3: Copy from VPS to Local

rsync -avz hxroot@YOUR_SERVER_IP:/remote/path/ /local/path/

Essential Rsync Options

  • -a - Archive mode (preserves permissions, timestamps, etc.)
  • -v - Verbose (shows what's being copied)
  • -z - Compress during transfer
  • -P - Show progress and keep partial files
  • --delete - Delete files in destination that aren't in source
  • --exclude - Exclude specific files/directories
  • -n - Dry run (show what would happen without actually copying)
  • -e ssh - Use SSH as transport (default, but can specify port)

Common Examples

Sync a directory with progress:

rsync -avzP /var/www/ hxroot@YOUR_SERVER_IP:/var/www/

Sync with SSH on custom port:

rsync -avz -e "ssh -p 2222" file.txt hxroot@YOUR_SERVER_IP:/root/

Exclude node_modules and .git directories:

rsync -avz --exclude='node_modules' --exclude='.git' /project/ hxroot@YOUR_SERVER_IP:/project/

Delete files in destination not in source:

rsync -avz --delete /local/folder/ hxroot@YOUR_SERVER_IP:/remote/folder/

Dry run (test without copying):

rsync -avzn file.txt hxroot@YOUR_SERVER_IP:/root/

Limit bandwidth to 1Mbps:

rsync -avz --bwlimit=1024 largefile.zip hxroot@YOUR_SERVER_IP:/root/

Backup Script with Rsync

#!/bin/bash
# Incremental backup using rsync
BACKUP_DIR="/backup/$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR
rsync -avz --link-dest=/backup/previous /var/www/ $BACKUP_DIR/
# Update previous symlink
rm -f /backup/previous
ln -s $BACKUP_DIR /backup/previous
echo "Backup completed to $BACKUP_DIR"

This creates incremental backups using hard links.

Rsync as a Cron Job

Schedule automatic sync every hour:

crontab -e

Add:

0 * * * * rsync -avz /important/data/ hxroot@YOUR_SERVER_IP:/backup/data/

Common Rsync Use Cases

  • Website deployment - Sync local code to production server
  • Database backups - Sync SQL dumps to backup server
  • Log file archiving - Move old logs to storage server
  • Server migration - Sync entire server to new host
  • Offsite backups - Mirror data to remote location

Rsync Performance Tips

  • Use -W (whole files) for very large files over fast networks
  • Use --inplace for large files to avoid temporary copies
  • Use --partial to keep partially transferred files
  • Compression (-z) helps with text files but slows for binaries

Advanced: Rsync Daemon Mode

For frequent syncs to same server, set up rsync daemon:

On server, edit /etc/rsyncd.conf:

[backup]
path = /backup
comment = Backup Directory
read only = yes
list = yes
auth users = backupuser
secrets file = /etc/rsyncd.secrets

Then connect with:

rsync -avz rsync://backupuser@YOUR_SERVER_IP/backup/ /local/backup/

Troubleshooting

Permission denied: Check user permissions on both ends.

Connection refused: Verify SSH works (ssh user@host).

Rsync not found: Install rsync on both local and remote machines.

Slow transfer: Try without compression (-z) for already compressed files (zip, gz, mp4).

✅ You can now efficiently sync files between your local computer and Hostxpeed VPS using rsync.

Was this article helpful?