Basic guide on how to use restic for local backups

 Reading time ~4 minutes


Even though most of my data (mostly code and a few personal documents) is already in online repositories, cloud services or external hard drives, I still think that having a backup that can be quickly restored is important.

However I’ve always had a difficult relationship with backups tools. They were either hard to use, too slow or cluttered with unnecessary functions therefore I’ve never found a backup program that fully clicked for me.

That changed when I discover Restic.

Restic is a modern backup program that is fast, efficient and secure. It works on all three major operating systems (Linux, macOS, Windows) and it’s written in Go.

Its design principles fully resonate with me:

  • Easy: Doing backups should be a frictionless process, otherwise you might be tempted to skip it.
  • Fast: Nobody does backups if it takes too much time. Restoring backups should also be fast.
  • Secure: Restic uses cryptography to guarantee confidentiality and integrity of your data.
  • Efficient: With the growth of data, additional snapshots should only take the storage of the actual increment.

For all these reasons I was eager to try it.


The installation process is straightforward and well documented. Once the process is done you can verify the version by running the following command

$ restic version
restic 0.14.0 compiled with go1.19 on linux/amd64

Next you can configure autocompletion to write a bash completion script compatible for your shell. In my case (Ubuntu/bash) the command is

$ sudo ./restic generate --bash-completion /etc/bash_completion.d/restic
writing bash completion file to /etc/bash_completion.d/restic

The next step is to write down a list of excluded paths and files that you don’t want to backup. Think about as .gitignore equivalent. In my case I have an excluded.txt file in my Home directory with this content:


Similarly you obviously want to define which paths and files should be included in your backup. Again this can be achieved by creating a list of files and paths inside a text file. In my case I have an included.txt file in my Home directory with paths to the Desktop, Documents and work directories.

The last step before running the actual backup, is the repository initialization. A “repository” is simply a directory containing a set of subdirectories and files created by restic to store your backups, some corresponding metadata and encryption keys.

The repository can be a local directory, but restic natively supports many more backends for storing backups. Just to name a few:

  • sftp server (via SSH)
  • HTTP REST server (protocol, rest-server)
  • Amazon S3 (either from Amazon or using the Minio server)
  • OpenStack Swift
  • BackBlaze B2
  • Microsoft Azure Blob Storage
  • Google Cloud Storage

To initalize a local repository the command is the following:

$ restic init --repo /media/maurizio/PortableSSD/backups
enter password for new repository:
enter password again:
created restic repository 085b3c76b9 at /media/maurizio/PortableSSD/backups

As you can see to access the repository, a password (also called a key) must be specified. Losing your password means that your data is irrecoverably lost so make sure to store it in a safe place.

Finally you can perform the first backup using the backup command. You can try to perform it in dry run mode to see what would happen without modifying the repository:

In our case the syntax is:

$ restic -r /media/maurizio/PortableSSD/backups backup --exclude-file=excluded.txt --files-from included.txt --verbose --dry-run
open repository
enter password for repository:
repository a9e6814d opened (repository version 2) successfully, password is correct
lock repository
using parent snapshot ad77202c
load index files
start scan on [/home/maurizio]
start backup on [/home/maurizio]
scan finished in 13.791s: 109720 files, 14.428 GiB

Files:        6232 new,  6248 changed, 97240 unmodified
Dirs:         1021 new,  3229 changed, 18638 unmodified
Data Blobs:  10522 new
Tree Blobs:   4066 new
Would add to the repository: 324.453 MiB (168.406 MiB stored)

processed 109720 files, 14.428 GiB in 0:16

Remove the --dry-run flag to perform the backup.

At the end of the process you can run the snapshot command to check the list of snapshots to verify that it actually created the backup:

$ restic -r /media/maurizio/PortableSSD/backups snapshots
enter password for repository:
repository a9e6814d opened (repository version 2) successfully, password is correct
ID        Time                 Host                Tags        Paths
ad77202c  2023-08-17 22:10:13  maurizio                        /home/maurizio
1 snapshot

I’ll document how to restore a snapshot once I need to do it 😃

comments powered by Disqus

The subtleties of ElasticSearch synonyms


The synonyms feature in ElasticSearch is very powerful, but just like most of the ElasticSearch features, it …