restic -r sftp:backup@198.51.100.20:/srv/restic init, back up with restic backup /etc /home /var/www, keep a set number of versions with restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune, and restore with restic restore latest --target /tmp/restore. Only changed data is uploaded.
Before you start
- Connect with SSH. Commands use
sudo; root users can leave it out. Backups run as root so they can read every file. - Decide where the repository (restic’s storage folder) lives: another server over SFTP, S3-compatible object storage, or any service rclone supports.
- For SFTP, set up an SSH key for root so restic can log in without a password.
How to install restic
- Ubuntu / Debian
- AlmaLinux / Rocky
- Fedora
restic version. Ubuntu 24.04 ships restic 0.16.4. If you need a newer version, use the official binary from the restic project, which you can update with restic self-update (this does not work for distribution packages).
How to create a restic repository
1
Create a password file
2
Choose the repository location
- SFTP (another server)
- S3-compatible storage
- Through rclone
sftp://backup@198.51.100.20:2222//srv/restic.created restic repository … at ….How to back up with restic
Save the settings in an environment file so you don’t type them every time:sudo chmod 600 /root/.restic/env.
Then run a backup:
How to list snapshots and delete old ones
forget on its own only removes the snapshot list entries; --prune deletes the data no snapshot needs any more. Add --dry-run to see what would be removed first. Afterwards, check the repository:
no errors were found.
How to restore files from a restic backup
1
Find the file
2
Restore to a temporary folder
/tmp/restore/etc/nginx/nginx.conf. Use a snapshot ID such as 578b9a8f instead of latest for an older version.3
Copy back what you need
Compare the restored files with the live ones, then copy them into place.
How to run restic backups automatically
Create/usr/local/bin/restic-backup.sh:
sudo chmod 700 /usr/local/bin/restic-backup.sh and add it to root’s crontab (sudo crontab -e):
Frequently asked questions
Is restic encrypted?
Yes. Everything in the repository is encrypted with your password before it leaves the server, so the storage provider cannot read it.What does “repository is already locked” mean?
Another restic command is running or one was interrupted. If you are sure nothing else is running, remove stale locks withrestic unlock.
Can I back up several servers to one repository?
Yes. Snapshots record the host name, andforget groups snapshots by host and paths by default, so each server keeps its own versions. Every server needs the repository password.
restic or rsync: which should I use?
Use restic when you want encrypted, versioned backups on storage you don’t fully trust. Use rsync when you want a plain, readable copy on another server.Related guides
VPS and dedicated server guides
Every guide in this section.
Back up a Linux server
What to back up and which tool to use.
Back up to cloud storage
Set up rclone remotes.
Back up with rsync
Plain copies over SSH.
VPS Panel backups
Full-disk backups in the panel.
Checked against the official restic documentation on 4 November 2026;
init, backup, snapshots, forget --prune, check, ls and restore tested on Ubuntu 24.04 LTS (restic 0.16.4) with a local repository. Commands can differ on other distributions or releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026