EN · $ USD
Security, Backups and Cloud Storage

How to Automate Server Backups to the Cloud with rclone

7 min read Updated: Sunucu Atlas technical team

In short

rclone is an open-source command-line tool that copies files from a server to SFTP, WebDAV and dozens of cloud services. To automate backups, you define the target storage with rclone config, add a crypt layer to encrypt files before they leave the server, then run a script that dumps databases and archives files every night via cron, and delete old backups with --min-age.

In this guide
  1. The Big Picture: What We'll Build
  2. 1. Install rclone
  3. 2. Configure the Remote Storage
  4. 3. Create an Encrypted (crypt) Remote
  5. 4. Write the Backup Script
  6. 5. Schedule It with cron
  7. 6. Verify and Test a Restore
  8. 7. Get Alerts When a Backup Fails
  9. Common Problems
  10. Next Step: Choose a Safe Destination for Your Backups

rclone is an open-source command-line tool that copies, syncs and verifies files from your server to remote storage. It works with SFTP, WebDAV, S3-compatible storage and many cloud services. In this guide, we'll build a complete setup that archives the web files and databases on a Linux server every night, encrypts them, sends them to cloud storage and automatically deletes backups older than a set age.

The Big Picture: What We'll Build

  1. The server creates a database dump and a file archive.
  2. rclone uploads these archives to remote storage through a crypt (encryption) layer.
  3. Backups older than a set number of days are deleted on the remote side.
  4. The whole process runs on its own every night via cron and writes a log file.

Any storage that supports SFTP and WebDAV can be the target. In the examples, we use Sunucu Atlas's AtlasDrive cloud storage, which supports SFTP, WebDAV and rclone; the commands are ready to test on Ubuntu and Debian.

1. Install rclone

The version in distribution repositories is usually outdated. Install the latest version with the official install script:

sudo apt update && sudo apt install -y curl unzip
curl https://rclone.org/install.sh | sudo bash
rclone version

2. Configure the Remote Storage

Option A: SFTP target (recommended)

SFTP is generally more efficient than WebDAV for large files and bulk transfers. Using an SSH key instead of a password is more secure. First, create a key dedicated to backups:

sudo ssh-keygen -t ed25519 -f /root/.ssh/atlas_yedek -N "" -C "yedek@sunucu1"

If your storage service supports adding a public key, add the contents of /root/.ssh/atlas_yedek.pub there; if not, continue with a password. Then start the interactive configuration:

sudo rclone config

Choose n (new remote), enter atlas as the name and sftp as the type; then enter the server address, username and port (the value in your service details, usually 22). The result is a section like this in /root/.config/rclone/rclone.conf:

[atlas]
type = sftp
host = sftp-adresiniz
user = kullanici_adiniz
port = 22
key_file = /root/.ssh/atlas_yedek

Option B: WebDAV target

Use WebDAV if your server only allows outbound HTTPS. In rclone config, choose webdav as the type and other as the vendor. When you enter the password, rclone stores it obscured in its own format:

[atlas-dav]
type = webdav
url = https://webdav-adresiniz/
vendor = other
user = kullanici_adiniz
pass = *** rclone tarafından gizlenmiş parola ***

Test the connection and create a folder for backups:

sudo rclone lsd atlas:
sudo rclone mkdir atlas:yedekler

3. Create an Encrypted (crypt) Remote

crypt is a transparent encryption layer that sits on top of another remote. File contents, and optionally file and folder names, are encrypted before they leave your server. On the storage side, only encrypted files with meaningless names are visible.

Add a new remote with sudo rclone config: name atlas-sifreli, type crypt, target atlas:yedekler. Set filename encryption to standard and directory name encryption to true, and choose a strong password plus a second password (salt).

[atlas-sifreli]
type = crypt
remote = atlas:yedekler
filename_encryption = standard
directory_name_encryption = true
password = *** gizlenmiş ***
password2 = *** gizlenmiş ***

Critical warning: If you lose your crypt passwords, nobody can open your backups, including you. Keep a copy of the rclone.conf file and the passwords off the server, for example in a password manager. Your ability to restore if the server is completely lost depends on it.

Restrict the permissions on the config file:

sudo chmod 600 /root/.config/rclone/rclone.conf

4. Write the Backup Script

The script below dumps all MySQL/MariaDB databases and archives the web directory, uploads them to the encrypted remote, then deletes backups older than 30 days remotely and older than 3 days locally. Adjust the paths for your server:

sudo nano /usr/local/bin/bulut-yedek.sh
#!/usr/bin/env bash
set -euo pipefail

SUNUCU="$(hostname -s)"
TARIH="$(date +%F_%H%M)"
YEREL="/var/backups/bulut"
HEDEF="atlas-sifreli:${SUNUCU}"
UZAK_SAKLAMA="30d"

mkdir -p "${YEREL}"

# 1) Databases (consistent, lock-free dump for InnoDB)
mysqldump --single-transaction --quick --routines --events --all-databases \
  | gzip > "${YEREL}/db_${TARIH}.sql.gz"

# 2) Web files
tar -czf "${YEREL}/www_${TARIH}.tar.gz" -C /var www

# 3) Copy to the cloud encrypted (copy never deletes anything on the remote)
rclone copy "${YEREL}" "${HEDEF}" \
  --transfers 4 --checkers 8 --bwlimit 50M \
  --log-file /var/log/rclone-yedek.log --log-level INFO

# 4) Delete old backups on the remote
rclone delete "${HEDEF}" --min-age "${UZAK_SAKLAMA}" \
  --log-file /var/log/rclone-yedek.log --log-level INFO
rclone rmdirs "${HEDEF}" --leave-root

# 5) Keep only the last 3 days locally
find "${YEREL}" -type f -mtime +3 -delete

echo "$(date '+%F %T') yedek tamam"
sudo chmod 700 /usr/local/bin/bulut-yedek.sh
sudo /usr/local/bin/bulut-yedek.sh

When the script runs as root, mysqldump usually connects without a password on Ubuntu MySQL/MariaDB installs via unix socket authentication. If it can't connect, put the credentials in /root/.my.cnf and protect the file with chmod 600; never hard-code the password in the script.

copy vs. sync

rclone copy only sends new and changed files and never deletes anything on the destination. rclone sync makes the destination an exact mirror of the source and deletes files from the destination that aren't in the source. If you use sync for backups, files accidentally deleted on the server or encrypted by ransomware get mirrored to the cloud too. That's why you should use copy plus a separate retention step for backups. When trying a new command, add --dry-run first to see what it will do.

5. Schedule It with cron

Open the root user's crontab:

sudo crontab -e

Add this line to run it every night at 3:30 AM. flock prevents a new run from starting before the previous one finishes:

30 3 * * * /usr/bin/flock -n /run/bulut-yedek.lock /usr/local/bin/bulut-yedek.sh >> /var/log/bulut-yedek.log 2>&1

For cron syntax and common mistakes, see our cron job setup guide. Schedule the backup for your site's lowest-traffic hours and cap bandwidth with --bwlimit so your live services aren't affected.

6. Verify and Test a Restore

A backup that's never been restored is a backup that's never been proven to work. Run these checks regularly:

# List remote backups (with decrypted names)
sudo rclone lsl atlas-sifreli:$(hostname -s)

# Compare integrity of the local copy and the encrypted remote copy
sudo rclone cryptcheck /var/backups/bulut atlas-sifreli:$(hostname -s) --one-way

# Download a backup and test that the archive opens
sudo rclone copy atlas-sifreli:$(hostname -s)/www_2026-12-01_0330.tar.gz /tmp/geri/
tar -tzf /tmp/geri/www_2026-12-01_0330.tar.gz | head

The most reliable check is to restore a database dump to a separate test environment at least once a month and confirm the application loads. Keep an eye on the logs too: grep -i error /var/log/rclone-yedek.log should return nothing.

7. Get Alerts When a Backup Fails

A backup that fails silently is more dangerous than no backup at all, because you think you're safe. Having the script stop on errors with set -e is a good start, but someone needs to see it. The simplest approach is to extend the cron line so it sends an alert when the script fails:

30 3 * * * /usr/bin/flock -n /run/bulut-yedek.lock /usr/local/bin/bulut-yedek.sh >> /var/log/bulut-yedek.log 2>&1 || curl -fsS -m 10 "https://izleme-adresiniz/yedek-basarisiz"

Replace the address with the URL of your monitoring service, your own Telegram bot or an n8n webhook. A reverse check is even more reliable: the script sends an "I'm alive" heartbeat on every successful run, and the monitoring service alerts you if that heartbeat doesn't arrive within a set time. That way you also catch cases where the server goes down completely.

Common Problems

  • Works manually but not in cron: cron has a restricted PATH. Use full paths to commands in the script, or add PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin at the top of the script. If you configured rclone with sudo, make sure cron also runs as root.
  • Local disk fills up: Archives are created locally before upload. Shorten local retention; for disk cleanup, see our Linux server disk full guide.
  • Slow uploads: Try SFTP instead of WebDAV and increase the --transfers value.

Next Step: Choose a Safe Destination for Your Backups

Keeping backups on the same server, or on the same disk at the same provider, doesn't give you real protection; you need separate storage. A plan like AtlasDrive 250 GB, with SFTP and WebDAV access, rclone compatibility, private isolated storage and brute-force attack protection, is a direct fit for the setup in this guide. If you don't have a server to back up yet, check out our Ryzen Premium VDS plans with root access, KVM virtualization and NVMe disks. For all command options, the official rclone documentation is the most up-to-date source.

Frequently asked questions

What's the difference between rclone copy and sync?

copy only sends new and changed files to the destination and never deletes anything there. sync makes the destination identical to the source and also deletes files from the destination that were deleted from the source, so copy is the better choice for backups.

If I forget my rclone crypt password, can I still open my backups?

No. Encrypted files can't be decrypted without the crypt passwords. Keep a copy of the rclone.conf file and the passwords in a safe place off the server.

How do I automatically delete old backups with rclone?

Use the rclone delete command with the --min-age flag; for example, --min-age 30d deletes files older than 30 days. Then clean up empty folders with rclone rmdirs.

Should I use SFTP or WebDAV with rclone?

SFTP is generally more efficient for large files and bulk transfers. If your server only allows outbound HTTPS, you can use WebDAV.

Will my site slow down during backups?

Archiving and uploading use CPU, disk and bandwidth. Scheduling backups overnight and capping bandwidth with --bwlimit keeps the impact to a minimum.

For this guide

Recommended plans

With SFTP, WebDAV and rclone compatibility, AtlasDrive cloud storage is ready to store your server backups automatically in a separate, private space.

Recommended

50 GB Storage

$13.76/mo

+VAT

  • LocationIstanbul
  • Web File Manager (Browser Access)
  • SFTP Access
  • WebDAV (Mount as a Network Drive)
  • SSL-Encrypted Connection

100 GB Storage

$27.53/mo

+VAT

  • LocationIstanbul
  • Web File Manager (Browser Access)
  • SFTP Access
  • WebDAV (Mount as a Network Drive)
  • SSL-Encrypted Connection

250 GB Storage

$68.82/mo

+VAT

  • LocationIstanbul
  • Web File Manager (Browser Access)
  • SFTP Access
  • WebDAV (Mount as a Network Drive)
  • SSL-Encrypted Connection

Cloud Storage — tüm paketler Ryzen Premium VDS — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.