Skip to content

Knowledge base

Search every guide

Automatic server backups to storage

Back up a Linux server every night to Box or Object storage.

On this page

A simple, reliable way is restic, which encrypts and deduplicates your backups.

Set up (once)

apt install -y restic
export RESTIC_REPOSITORY="sftp:USERNAME@HOSTNAME:/backups/server1"
export RESTIC_PASSWORD="choose-a-long-password"
restic init

For Object Storage, use s3:https://ENDPOINT/my-bucket/server1 as the repository and set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Back up every night

Put the variables and these commands in a script and run it from cron:

restic backup /etc /var/www /home
restic forget --keep-daily 7 --keep-weekly 4 --prune

Restore

restic snapshots
restic restore latest --target /restore

Keep the restic password safe somewhere else. Without it, the backups can't be read, even by us.

Test a restore every few months. See our backup strategy guide.