Server backups with RClone & Restic

# 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 โ๏ธ!