rclone and backups
Configure rclone for Z2, sync files, and keep encrypted restic backups from a VPS or dedicated server — including a tested restore.
The most common use of Z2 is backups: a machine writes an archive to a bucket, and the bucket holds it independently of the machine.
Two tools cover almost every case: rclone for file sync, and restic for encrypted, deduplicated snapshots.
rclone
Install
curl https://rclone.org/install.sh | sudo bash
rclone version
Configure
Run rclone config and choose New remote, or create ~/.config/rclone/rclone.conf:
[z2]
type = s3
provider = Other
access_key_id = <key id>
secret_access_key = <secret>
endpoint = <endpoint from console>
region = <region from console>
force_path_style = true
force_path_style = true is required. Without it, rclone may build virtual-hosted URLs that Z2 does not serve.
Test and sync
rclone lsd z2:
rclone mkdir z2:my-bucket/backups
rclone sync /srv/data z2:my-bucket/backups/server1 --progress
sync makes the destination match the source, including deleting files at the destination that no longer exist locally. Use copy instead if you never want deletions propagated.
Verify
rclone check /srv/data z2:my-bucket/backups/server1 --size-only
A backup you have never read back is not a backup. Download one file and compare it:
rclone copy z2:my-bucket/backups/server1/app.db /tmp/restore-test/
cmp /srv/data/app.db /tmp/restore-test/app.db && echo OK
restic
restic stores encrypted, deduplicated snapshots. It needs a repository, which lives in the bucket.
Install and initialise
apt install -y restic
export RESTIC_PASSWORD="a long passphrase you store somewhere else"
restic -r s3:<endpoint from console>/my-bucket/restic init
Set the S3 credentials through the standard variables so restic can sign requests:
export AWS_ACCESS_KEY_ID="<key id>"
export AWS_SECRET_ACCESS_KEY="<secret>"
export AWS_DEFAULT_REGION="<region from console>"
Back up
restic -r s3:<endpoint>/my-bucket/restic backup /srv /etc --exclude-caches
restic -r s3:<endpoint>/my-bucket/restic snapshots
Restore
restic -r s3:<endpoint>/my-bucket/restic restore latest --target /tmp/restore
Test this on a spare directory at least once. The failure mode you are guarding against is discovering during an incident that the repository password or path was wrong.
Retention
restic -r s3:<endpoint>/my-bucket/restic forget \
--keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
--prune removes unreferenced data. Run it less often than backups; it is the expensive operation.
Schedule it
Use a systemd timer or cron. A cron entry that runs at 02:15 every day:
15 2 * * * root /usr/local/bin/z2-backup.sh >> /var/log/z2-backup.log 2>&1
Wrap credentials in the script with set -euo pipefail, and make it fail loudly. A silent backup failure is worse than no backup.
#!/usr/bin/env bash
set -euo pipefail
export AWS_ACCESS_KEY_ID="<key id>"
export AWS_SECRET_ACCESS_KEY="<secret>"
export AWS_DEFAULT_REGION="<region>"
export RESTIC_PASSWORD="$(cat /root/.restic-pass)"
restic -r s3:<endpoint>/my-bucket/restic backup /srv --exclude-caches
restic -r s3:<endpoint>/my-bucket/restic forget --keep-daily 7 --keep-weekly 4 --prune
Keep the password file readable only by root (chmod 600), and keep a copy somewhere other than the machine being backed up.
Capacity planning
Backups grow. Check Capacity in the console regularly, and leave headroom:
- A bucket's quota is fixed when it is created; it does not grow automatically.
- If a bucket fills up, writes fail.
restic pruneand retention policies keep growth predictable. - If the plan is full, create another bucket only if unallocated capacity remains; otherwise move to a larger plan.
Next
- rclone
- restic
- backup
- sync
- encryption
- cron
Ready to use this
S3-compatible buckets your existing tools already speak.
- No egress fees
- Per-bucket quotas from the console

