Back

Server backups with RClone & Restic

Server backups with RClone & Restic cover pic
3 min read
# Backups

Hi there๐Ÿ‘‹, When self-hosting or deploying applications on a server, external backups are a must. They protect you from data loss and make it easy to restore everything on a new server.

In this post, Iโ€™ll walk you through two CLI tools you can use to backup server data to S3-compatible storage: RClone and Restic.

RClone

  • RClone is a command-line tool, often seen as an alternative to aws-cli.
  • It supports almost every object storage provider โ€” AWS S3, Cloudflare R2, MinIO, Cloudinary, and more.
# Install rclone
sudo -v ; curl https://rclone.org/install.sh | sudo bash
  • Create a configuration, which will be used to backup files
rclone config

# Press n to create a new configuration
2025/09/28 10:54:58 NOTICE: Config file "/home/linux/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

# Give your configuration a name
# Next you'll prompted credentials and other options
Enter name for new remote.
name> cloudflare
  • Now letโ€™s upload a file using rclone
# rclone copy {remoteName}:{filePath} {backupPath}
rclone copy cloudflare:data.tar.gz ./
  • Now letโ€™s create a cron job to execute rclone periodically
# Create a script
nano rclone.sh

# Add these contents to rclone.sh
rclone copy cloudflare:data.tar.gz ./

# Give it executable permission
chmod +x rclone.sh

# Open crontab
crontab -e

# Add this line at the end (runs every minute for demo)
* * * * * sh /rclone.sh

Restic

  • Restic takes a different approach to backups.
  • The first backup creates a snapshot of your data.
  • Future backups only upload changes (like Git diffs).
  • This is very efficient for folder-based backups.

โš ๏ธ Restic encrypts all backups with a password. If you lose it, your data is gone.

# Install restic
sudo apt-get install restic
  • Restic repositories follow a specific structure inside your storage bucket:
my_s3_bucket
|
|-๐Ÿ“ data       (encrypted file contents / data blobs)
|-๐Ÿ“ index      (maps data blobs to repository)
|-๐Ÿ“ snapshots  (JSON metadata for each backup)
|-๐Ÿ“ keys       (encrypted repository keys)
|-๐Ÿ“„ config
  • Initialize a repository in S3
# Set S3 credentials
export AWS_ACCESS_KEY_ID=<MY_ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<MY_SECRET_ACCESS_KEY>

# Create a new restic repo
restic -r s3:s3.us-east-1.amazonaws.com/database init
  • Lets create a backup, Itโ€™ll create a snapshot which can use to restore later
restic -r s3:s3.us-east-1.amazonaws.com/database backup ~/work

# Example output
Files:        5307 new
Dirs:         1867 new
Added:        1.200 GiB (1.103 GiB stored)

snapshot 40dc1520 saved
  • Restore a snapshot:
# restic -r s3:{s3_URL}/{s3_bucketName} restore ${snapshotID} --target ${destinationPath}
restic -r s3:s3.us-east-1.amazonaws.com/database restore 40dc1520 --target /tmp/restore-work

Both RClone and Restic are powerful, flexible tools for server backups. Use RClone for simple copy-based backups, and Restic when you want incremental, deduplicated, and encrypted backups.

Thatโ€™s it for this post, thanks for reading. Stay tuned, and peace โœŒ๏ธ!