Set up encrypted off-site backups with restic in 15 minutes: repository, systemd timer, retention policy and a restore test. Works with any S3 or SFTP storage.
Daily snapshots from your provider are insurance against mistakes, not against losing the whole server. Real backups live somewhere else and are encrypted. restic does both, and it is one binary.
apt update && apt install -y restic
restic writes a single encrypted repository. It can live on S3, Backblaze B2, another server over SFTP, or even a second Buran VPS.
export RESTIC_REPOSITORY="sftp:backup@other-host:/srv/backups/myserver" export RESTIC_PASSWORD="a-long-unique-passphrase" restic init
Keep the passphrase in a password manager. If you lose it, the data is gone - that is the point of encryption. For automatic jobs, store it in an environment file readable only by root:
cat > /etc/restic.env <<'EOF' RESTIC_REPOSITORY=sftp:backup@other-host:/srv/backups/myserver RESTIC_PASSWORD=change-me EOF chmod 600 /etc/restic.env
set -a; . /etc/restic.env; set +a restic backup /etc /root /home /var/www --exclude-caches restic snapshots
Databases need a dump, not a file copy: a running PostgreSQL data directory is inconsistent. Dump first, then back up the dump folder. See our PostgreSQL guide for the dump command.
cat > /etc/systemd/system/restic-backup.service <<'EOF' [Unit] Description=restic backup [Service] Type=oneshot EnvironmentFile=/etc/restic.env ExecStart=/usr/bin/restic backup /etc /root /home /var/www --exclude-caches ExecStartPost=/usr/bin/restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune EOF cat > /etc/systemd/system/restic-backup.timer <<'EOF' [Unit] Description=Nightly restic backup [Timer] OnCalendar=*-*-* 03:30:00 Persistent=true [Install] WantedBy=timers.target EOF systemctl daemon-reload systemctl enable --now restic-backup.timer
set -a; . /etc/restic.env; set +a restic snapshots restic restore latest --target /tmp/restore-test ls -la /tmp/restore-test/etc
A backup you have never restored is a hope, not a backup. Repeat the test every few months - and check that the repository actually grows.
Anywhere except the machine you are backing up: object storage like Backblaze B2, another server over SFTP, or a second VPS. Backups on the same host do not survive a lost host.
restic deduplicates and compresses, so a typical server rarely grows more than a few GB per month of changes. 50–100 GB of remote storage is plenty for a small server.
Yes. Buran snapshots restore a whole machine in one click and are perfect for “I broke it five minutes ago”. Off-site restic backups cover hardware loss and operator mistakes that outlive the snapshot window.
Need a second machine to hold backups? Core VPS 4 at €12 works fine.