Make encrypted backups with restic
Updated 27 Nov 2026 backup restic encryption
Encrypted, deduplicated backups to another server or object storage.
Install
sudo apt install -y restic
Create a repository
On another server reached over SFTP (set up the SSH host in ~/.ssh/config):
sudo install -m 600 /dev/null /root/restic.pass
openssl rand -base64 32 | sudo tee /root/restic.pass > /dev/null
sudo restic -r sftp:backuphost:/srv/restic/web01 --password-file /root/restic.pass init
Save a copy of the password somewhere else. Without it the backup cannot be read.
Back up
sudo restic -r sftp:backuphost:/srv/restic/web01 --password-file /root/restic.pass backup /etc /var/www /var/backups/db
Keep and check
sudo restic -r REPO --password-file /root/restic.pass forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
sudo restic -r REPO --password-file /root/restic.pass check
sudo restic -r REPO --password-file /root/restic.pass snapshots
Restore
sudo restic -r REPO --password-file /root/restic.pass restore latest --target /tmp/restore
Replace REPO with the repository address.