Skip to main content
restic makes encrypted, deduplicated, versioned backups. Create a repository with 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

Check it with 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

Copy this password into a password manager now.
2

Choose the repository location

For a custom SSH port use the URL form: sftp://backup@198.51.100.20:2222//srv/restic.
You see created restic repository … at ….
The restic documentation is clear: if you lose the repository password, the data in it is lost for good. Nobody can recover it. Keep a copy of the password off the server.

How to back up with restic

Save the settings in an environment file so you don’t type them every time:
Make it readable only by root: sudo chmod 600 /root/.restic/env. Then run a backup:
Example output:
The next run uploads only data that changed. Dump your databases to a file first and include that file; see back up MySQL databases.

How to list snapshots and delete old ones

Keep 7 daily, 4 weekly and 6 monthly snapshots and free the space:
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:
Success ends with no errors were found.

How to restore files from a restic backup

1

Find the file

2

Restore to a temporary folder

Files appear under their full path, for example /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.
Restoring with --target / writes straight over your live files. Restore to a temporary folder first unless you are rebuilding a server.

How to run restic backups automatically

Create /usr/local/bin/restic-backup.sh:
Make it executable with sudo chmod 700 /usr/local/bin/restic-backup.sh and add it to root’s crontab (sudo crontab -e):
See schedule tasks with cron.

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 with restic unlock.

Can I back up several servers to one repository?

Yes. Snapshots record the host name, and forget 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.

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:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026