Back Up VPS Data to Cloud Storage with Rclone
Rclone is a command-line tool that syncs and copies data to a wide variety of cloud storage providers, including Google Drive, AWS S3, Azure Blob, Backblaze B2, Dropbox, OneDrive, and more. If you want to back up your VPS data to secure cloud storage automatically, Rclone is a robust, fast, and versatile choice with many providers to choose from.
Install Rclone on Your VPS
# Install using the official install script
curl https://rclone.org/install.sh | bash
# Or use apt (Ubuntu/Debian)
sudo apt update
sudo apt install rclone -y
# Verify the installation
rclone version
The first command downloads the latest binary. The apt version may not be the latest but is sufficient for most use cases.
Set Up Rclone Remote (Cloud Storage)
Rclone uses the term "remote" to refer to a cloud service you want to connect to. Run the config command for an interactive setup:
rclone config
Rclone will ask several questions:
- Name: Give the remote a name (e.g., "mydrive", "s3backup", "b2")
- Type: Choose the cloud service (Google Drive = drive, AWS S3 = s3, Backblaze = b2, etc.)
- Authentication: Select authentication method (OAuth token, API key, username/password)
Example setup for Google Drive:
name> mydrive
type> drive
scope> 1 # Full read-write access to Google Drive
token> (leave blank; rclone will open a browser to authorize)
Example setup for Backblaze B2:
name> b2backup
type> b2
account_id> [your-account-id]
app_key> [your-app-key]
hard_delete> true # Permanent deletion (not soft delete)
For AWS S3-compatible storage (e.g., Cloudflare R2, DigitalOcean Spaces):
name> s3
type> s3
provider> 1 # AWS
access_key_id> [your-key]
secret_access_key> [your-secret]
region> us-east-1 # Or your region
rclone listremotes
Test the Remote Connection
# List files in remote root
rclone lsd mydrive:
# List detailed file information
rclone ls mydrive:
# Check total size
rclone size mydrive:
If the commands work, authentication is successful.
Sync Data to Cloud
Rclone sync only transfers changed files, not everything each time:
# Sync local files to cloud
rclone sync /var/www/html/ mydrive:backup/webroot/
# Sync database backup
rclone sync /backup/mysql/ b2backup:backup/database/
# Sync with progress display
rclone sync /var/www/html/ mydrive:backup/webroot/ --progress
# Sync with verbose output showing changed files
rclone sync /var/www/html/ mydrive:backup/webroot/ -v
The difference between sync and copy:
rclone sync— Deletes files in destination if they don't exist in source (mirror principle)rclone copy— Copies only new files without deleting old ones
For backups, use copy to preserve history — keep each run in its own dated folder so old versions are never deleted (watch your storage usage grow over time, though):
# Copy each run into its own dated folder (nothing gets deleted)
rclone copy /backup/mysql/ b2backup:backup/$(date +%Y%m%d)/
Set Up Cron Job for Automated Backups
Create a backup script:
#!/bin/bash
# /usr/local/bin/rclone-backup.sh
set -euo pipefail
DATE=$(date +%Y%m%d_%H%M%S)
LOG_FILE="/var/log/rclone-backup.log"
{
echo "[$(date)] Starting Rclone backup..."
# Backup MySQL database
mysqldump -u root -p"${MYSQL_PASS}" --all-databases --single-transaction \
| gzip > "/backup/database-${DATE}.sql.gz"
echo "[$(date)] Database backup done"
# Sync to cloud
rclone sync /var/www/html/ b2backup:backup/webroot/ --progress --delete-during
echo "[$(date)] Web files sync done"
rclone sync /backup/database-*.sql.gz b2backup:backup/database/ --progress --delete-during
echo "[$(date)] Database sync done"
# Clean old local backups (older than 7 days)
find /backup -name "database-*.sql.gz" -mtime +7 -delete
echo "[$(date)] Old backups cleaned"
echo "[$(date)] Backup completed successfully"
} >> "$LOG_FILE" 2>&1
Make it executable:
chmod +x /usr/local/bin/rclone-backup.sh
Add to crontab to run automatically:
# Crontab entry (run at 02:00 every night)
0 2 * * * MYSQL_PASS="yourpassword" /usr/local/bin/rclone-backup.sh
Edit crontab with:
sudo crontab -e
Or for the root user:
sudo crontab -e -u root
--bwlimit to limit upload speed, e.g., --bwlimit 5M, to avoid consuming user bandwidth
Verify That Rclone Is Working Correctly
# View uploaded files
rclone lsd b2backup:backup/
# Check sync (dry run)
rclone sync /var/www/html/ b2backup:backup/webroot/ --dry-run
# Verify files
rclone check /var/www/html/ b2backup:backup/webroot/
# View backup logs
sudo tail -50 /var/log/rclone-backup.log
# Check if cron ran
grep CRON /var/log/syslog | tail -10
Common Issues & Troubleshooting
Error: "403 Forbidden" or "Access Denied" during upload
Your token or API key has expired. Re-authenticate:
rclone config reconnect b2backup:
# Or delete and reconfigure
rclone config delete b2backup
rclone config
Error: "Timeout" during sync
Network instability or files too large. Try retry and longer timeout:
rclone sync /var/www/html/ b2backup:backup/webroot/ \
--retries 5 \
--low-level-retries 10 \
--timeout 10m
Rclone sync is very slow
Use parallel transfers:
rclone sync /var/www/html/ b2backup:backup/webroot/ \
--transfers 4 \
--checkers 8
Old files still exist in cloud even though deleted from webroot
Verify the files truly exist in source. If deleted locally, sync with --delete-during to also delete in destination:
rclone sync /var/www/html/ b2backup:backup/webroot/ --delete-during --dry-run
# (Remove --dry-run if confident)
Rclone in cron doesn't work but runs fine manually
Issue may be missing environment variables. Check:
# Find where Rclone config is stored
rclone config file
# If needed, specify config file location in cron
0 2 * * * RCLONE_CONFIG_FILE=/root/.config/rclone/rclone.conf /usr/local/bin/rclone-backup.sh
Frequently Asked Questions
Should I use rclone sync or copy for backups?
Use copy if you want to keep a history of files by storing each day in a separate folder (e.g., `/backup/2026-07-08/`). Use sync if you only want the cloud to mirror the current server state.
Which cloud storage is cheapest and best?
Backblaze B2 and Cloudflare R2 are the most affordable. R2 has no egress fees, making it better if you restore frequently. B2 offers a free tier of 10 GB. For frequent restores, R2 is more economical.
How do I restore specific files from cloud?
Use rclone copy to download:
rclone copy b2backup:backup/webroot/index.html /tmp/restored/
Rclone is highly flexible and secure for backing up VPS data to the cloud. Set it up correctly once, then let cron handle it automatically. You can sleep peacefully knowing your VPS data is safely backed up to the cloud.
When backing up VPS data, regularly monitor your server and domain health. Tools like dnsxray.com provide free checks for SSL expiration, DNS configuration, Security Headers, and other issues before they become critical.
For those seeking a Thai-based VPS provider with strong uptime guarantees and reliable support, check out AsiaGB's VPS hosting, which offers both Linux and Windows options with clear backup policies.