Quick start (up and running in 5 minutes)
Need to quickly push data from CentOS Stream 9 to cloud storage without getting tangled in dependency hell? Run these four steps:
# 1. Install official Rclone via automated script
sudo curl https://rclone.org/install.sh | sudo bash
# 2. Verify version after installation
rclone version
# 3. Open wizard to configure a cloud storage remote
rclone config
# 4. Test copying a directory to the cloud (e.g. remote named gdrive)
rclone copy /var/www/backup gdrive:backup-server --progress
Rclone is written in Go. The entire utility ships as a single standalone binary, consuming under 30MB of RAM when running in the background on CentOS Stream 9.
Why Rclone?
Back in 2021 when CentOS 8 reached an unexpected early end-of-life, our team had to rush migrating 5 production servers to Rocky Linux in just one week. The hard-learned lesson was clear: without an OS-independent backup mechanism, every server recovery or distro switch becomes a disaster. Rclone completely solves this problem. It works similarly to the familiar rsync command, but supports more than 70 cloud storage providers. Here is how to set it up with the two most popular services: Google Drive and AWS S3.
1. Configuring Google Drive on a headless server
CentOS Stream 9 servers typically run in headless mode without a GUI web browser. Therefore, you will borrow the web browser on your personal laptop to retrieve an OAuth authentication token.
Run the command to launch the configuration wizard:
rclone config
- Choose
n(New remote), enter name:gdrive. - Choose Storage type: enter
driveor the corresponding number for Google Drive. client_idandclient_secret: You can leave these blank to use default credentials. However, it is strongly recommended to create your own OAuth Client ID on Google Cloud Console to prevent Rate Limit Exceeded errors when backing up large files.- Scope: choose
1(Full access to all files). service_account_file: Leave blank if using a personal account or standard Google Workspace.Edit advanced config?: choosen.Use web browser to automatically authenticate?: Choosen(mandatory since the server has no GUI).
At this point, the server terminal will pause and display a command like: rclone authorize "drive" "...". Open a terminal on your laptop (with Rclone installed), paste that exact command, and press Enter. A browser window will pop up prompting you to log into Google and grant permissions. Once completed, your laptop will generate a JSON access token string. Copy the entire string and paste it back into your CentOS Stream 9 terminal to finish.
2. Configuring an AWS S3 Bucket
Connecting to AWS S3 is much simpler. You only need an IAM Access Key and Secret Key—no intermediate browser required:
# Rerun the configuration wizard
rclone config
- Choose
n, enter name:s3_backup. - Choose Storage type:
s3. - Choose Provider:
AWS. env_auth: choosefalse.- Enter the
access_key_idandsecret_access_keyfrom an IAM user with read/write permissions for the bucket. - Choose the
regionclosest to you (e.g.ap-southeast-1for Singapore to reduce latency). acl: chooseprivateto prevent data leaks to the public Internet.
List existing buckets to test the connection:
rclone lsd s3_backup:
Advanced: Automating Scheduled Backups with Bash Script & Systemd Timer
Stop running backup commands manually every day. Consolidate the entire workflow into a closed loop: archive data, sync to two independent cloud providers, and automatically prune expired backups.
Creating the complete backup script
Create an executable script at /usr/local/bin/auto-backup.sh:
#!/usr/bin/env bash
set -euo pipefail
BACKUP_SRC="/var/www/html"
BACKUP_DIR="/backup/temp"
DATE=$(date +"%Y%m%d_%H%M%S")
ARCHIVE_NAME="web_data_${DATE}.tar.gz"
LOG_FILE="/var/log/rclone-backup.log"
mkdir -p "${BACKUP_DIR}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting data compression..." >> "${LOG_FILE}"
tar -czf "${BACKUP_DIR}/${ARCHIVE_NAME}" -C "${BACKUP_SRC}" .
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Uploading backup to Google Drive..." >> "${LOG_FILE}"
rclone copy "${BACKUP_DIR}/${ARCHIVE_NAME}" gdrive:server-backups/ \
--bwlimit 10M \
--log-file="${LOG_FILE}" \
--log-level NOTICE
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Uploading backup to AWS S3 Standard-IA..." >> "${LOG_FILE}"
rclone copy "${BACKUP_DIR}/${ARCHIVE_NAME}" s3_backup:my-prod-backups/ \
--s3-storage-class STANDARD_IA \
--log-file="${LOG_FILE}"
# Remove local compressed archive to free up disk space
rm -f "${BACKUP_DIR}/${ARCHIVE_NAME}"
# Clean up cloud backups older than 30 days
rclone delete gdrive:server-backups/ --min-age 30d
rclone delete s3_backup:my-prod-backups/ --min-age 30d
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backup cycle completed!" >> "${LOG_FILE}"
Grant execution permissions to the script:
sudo chmod 700 /usr/local/bin/auto-backup.sh
Setting up daily automated runs with a Systemd Timer
On CentOS Stream 9, systemd timers replace traditional cron jobs thanks to superior error handling and direct integration with journalctl.
Create a service unit file at /etc/systemd/system/rclone-backup.service:
[Unit]
Description=Automated Cloud Backup Service
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/auto-backup.sh
Create a timer unit file set to run daily at 2:00 AM at /etc/systemd/system/rclone-backup.timer:
[Unit]
Description=Run Rclone backup daily at 2:00 AM
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
RandomizedDelaySec=300
[Install]
WantedBy=timers.target
Reload systemd and enable the timer:
sudo systemctl daemon-reload
sudo systemctl enable --now rclone-backup.timer
sudo systemctl list-timers rclone-backup.timer
Production Best Practices
1. Rate-limit bandwidth to avoid saturating your network
If your server handles 5,000 concurrent visitors and a backup operation consumes the full 100Mbps port, your website will freeze immediately. Use the --bwlimit flag with scheduled time slots:
# Peak hours (08:00 - 22:00) throttle to 2MB/s; full speed overnight
rclone copy /data gdrive:backup --bwlimit "08:00,2M 22:00,off"
2. Always encrypt data before sending it to the Cloud (Crypt Backend)
Storing raw databases or application code containing .env files on public cloud providers poses major security risks. Rclone supports client-side AES-256-GCM encryption out of the box:
rclone config
# Choose remote type 'crypt', pointing directly to 'gdrive:backup-secret'
# Rclone will automatically encrypt both filenames and contents before transmission
3. Always test with Dry-run before rotating or syncing data
The rclone sync command behaves differently from rclone copy. It deletes files at the destination if they do not exist at the source. A single typo in your source path can wipe out your entire cloud backup. Make it a habit to append --dry-run first:
rclone sync /var/www gdrive:backup --dry-run
4. Save 45% on S3 storage costs
S3 Standard costs roughly $0.023/GB/month. If you back up 500GB of data with a 30-day retention policy, pass the --s3-storage-class STANDARD_IA flag ($0.0125/GB). This cuts your storage bill almost in half. Avoid Glacier Flexible Retrieval for 30-day retention cycles, as it enforces a 90-day minimum storage fee even if objects are deleted early.