Getting started (with configuration)


Here’s a copy of a very simple Getting Started with restic and resticprofile.

The new syntax completion of the resticprofile configuration file makes it very easy to create a configuration without remembering all the restic flags that you need.


resticprofile is one of many automation tools for restic, also called a wrapper.

In a nutshell, resticprofile provides a configuration file and a runner that will generate all the necessary calls to restic.

Unless you’re using the resticprofile Docker image, you need to have restic installed on your machine.

Choose your favourite format

resticprofile configuration file can be written in:

  • TOML : configuration file with extension .toml or .conf
  • YAML : configuration file with extension .yaml
  • JSON : configuration file with extension .json
  • HCL: configuration file with extension .hcl

We recommend using either TOML or YAML.

JSON is fine for auto generated configurations but is not the easiest format for a human to read and write.

HCL can be interesting if you already use a tool from the Hashicorp stack otherwise that’s yet another format to learn.

Configure your text editor

We’re going to show you how to get documentation and auto-completion for the resticprofile configuration using Visual Studio Code.

You can use any other editor that recognise the JSON schema. The same JSON schema can be used for JSON, TOML and YAML file formats.


In Visual Studio Code, you need to install an extension that supports completion and syntax validation using a JSON schema.

For example you can install the Even Better TOML extension:

TOML extension


Same for YAML: in Visual Studio Code you need to install an extension like the one provided by Red Hat to understand the shape of your configuration file.

YAML extension

Write your first configuration file

The configuration file is essentially a list of profiles containing a list of commands and flags.

A profile defines:

  • a restic repository (flag repository)
  • how to access your restic repository (like password-file)
  • a list of commands (like backup):
    • which files to include in a backup (flag source)
    • when to backup them (we’ll see that later)
    • any other restic flags you would add to the command line (like verbose)

In this example, we’re going to call our profile default. You don’t need to specify the profile name on the command line when using this name (default).

Create a file named profiles with the extension of your choice (.toml, .yaml, .hcl or .json)


# indentation is not needed but it makes it easier to read ;)
version = "1"

  repository = "local:/backup"
  password-file = "password.txt"

    verbose = true
    source = [ "/home" ]


# yaml-language-server: $schema=

version: "1"

  repository: "local:/backup"
  password-file: "password.txt"

    verbose: true
      - "/home"

Generate a secure password

resticprofile has a handy command that can generate a cryptographically secure password file for you:

resticprofile generate --random-key > password.txt

Initialize your repository

Now that you have a password file, you can initialize your restic repository:

resticprofile init

Here’s an example of the result:

2023/03/25 15:46:48 using configuration file: profiles.yaml
2023/03/25 15:46:48 profile 'default': starting 'init'
created restic repository e21ab75046 at local:/backup

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
2023/03/25 15:46:51 profile 'default': finished 'init'

Test your first backup

Before going live, you can dry run your first backup by using the resticprofile --dry-run flag.

resticprofile --dry-run backup

And here’s the result:

2023/03/25 15:49:51 using configuration file: profiles.yaml
2023/03/25 15:49:51 profile 'default': starting 'backup'
2023/03/25 15:49:51 dry-run: /usr/local/bin/restic backup --password-file password.txt --repo local:/backup --verbose /home
2023/03/25 15:49:51 profile 'default': finished 'backup'

As you can see, resticprofile converted your backup profile into this command line:

/usr/local/bin/restic backup --password-file password.txt --repo local:/backup --verbose /home


Let’s stop a moment and analyse the command line: we passed the flag --dry-run before the command backup: it means the flag is used by resticprofile.

Let’s try again with the flag after the command:

resticprofile backup --dry-run

And the result is rather different:

2023/03/25 15:50:02 using configuration file: profiles.yaml
2023/03/25 15:50:02 profile 'default': starting 'backup'
open repository
repository e22aa770 opened (version 2, compression level auto)
created new cache in /Users/CP/Library/Caches/restic
lock repository
no parent snapshot found, will read all files
load index files
start scan on [/home]
start backup on [/home]
scan finished in 0.202s: 0 files, 0 B

Files:           0 new,     0 changed,     0 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Data Blobs:      0 new
Tree Blobs:      1 new
Would add to the repository: 346 B (292 B stored)

processed 0 files, 0 B in 0:00
2023/03/25 15:50:03 profile 'default': finished 'backup'

If you add flags after the command, the flags will be sent to restic instead. As you can see, restic simulated a backup of your /home folder.


Let’s imagine you want to backup your files every day during your lunch break.

Add a line in your configuration (in the default → backup section) with an option called schedule and a value of 12:30. Your configuration should now look like:


# indentation is not needed but it makes it easier to read ;)
version = "1"

  repository = "local:/backup"
  password-file = "password.txt"

    verbose = true
    source = [ "/home" ]
    schedule = "12:30"


# yaml-language-server: $schema=

version: "1"

  repository: "local:/backup"
  password-file: "password.txt"

    verbose: true
      - "/home"
    schedule: "12:30"

resticprofile can schedule work on macOS, Windows, most Unixes and Linux distributions: it is simply adding an entry in the default scheduler of your platform.

To schedule the backup of the default profile, simply type the command:

resticprofile schedule

Now your backup will run every day at 12:30. As simple as that!

Inline help

You can get help for any command at any time.

The help is available for both the resticprofile internal commands and all the restic commands.

resticprofile help

To get the help on a resticprofile command, simply use the help command or command -h:


$ resticprofile help generate

The "generate" command is used to create various resources and print them to stdout

  resticprofile [resticprofile flags] generate [command specific flags]

  --bash-completion                               generate a shell completion script for bash
  --config-reference [--version 0.15] [template]  generate a config file reference from a go template (defaults to the built-in markdown template when omitted)
  --json-schema [--version 0.15] [v1|v2]          generate a JSON schema that validates resticprofile configuration files in YAML or JSON format
  --random-key [size]                             generate a cryptographically secure random key to use as a restic keyfile (size defaults to 1024 when omitted)
  --zsh-completion                                generate a shell completion script for zsh

restic help

This is the same syntax to display the help from a restic command:

$ resticprofile init -h

The "init" command initializes a new repository.


Exit status is 0 if the command was successful, and non-zero if there was any error.

  resticprofile [resticprofile flags] [profile name.]init [flags]


Now have fun configuring your backups!


It seems useful! Thanks for that!

1 Like

I setup a profile with multiple groups and inheritance. It works great. Toml seems to be pleasant to work with.

Resticprofile is a fantastic tool!

Wish I had known sooner …


In your Toml examples the backslash is often escaped.

For example

restic-binary = "c:\\ProgramData\\chocolatey\\bin\\restic.exe"

But if you use single quotes in Toml no escaping is performed, so this would also work, right?

restic-binary = 'c:\ProgramData\chocolatey\bin\restic.exe"

Yes I believe it would also work. Actually, it would even handle / instead of \ (I know it’s a funny one)

restic-binary = "c:/ProgramData/chocolatey/bin/restic.exe"


Resticprofile is so good, I renamed it to restic.exe (or restic on Linux) actually :smile:

It can do everything basically and replaced all my batch files completely.

There is only one thing that I haven’t figured out yet (on WIndows)

On Windows my backup paths are relative (to avoid having the /C/ prefix in the backup), and because of that I have to run restic or resticprofile from the root folder (C:)

So my backup command looks like this currently

C:\Users\> pushd C:\ & resticprofile -v all.backup -v & popd

How could I move the change directory part to profiles.toml?

I tried

  run-before = 'pushd C:\'
  run-after = 'popd'
  run-after-fail = 'popd'

But that didn’t work unfortunately.

No that’s right you can’t do that: each run-* option is running in its own shell.

I never had any need for it yet, but I suppose I can add a root option to define the root of relative paths.

Awesome! That would be truly great!

And here maybe something not so essential. But I was wondering …

My backup command looks like that currently

resticprofile -v all.backup -v | tee restic_log.txt | sed "/^unchanged/d"

Obviously it would look nicer like that

resticprofile -v all.backup -v

with “pipe options” in the configuration file. Not sure if this is something easy to implement?

Just brainstorming.

Anyway, thanks again for resticprofile! Awesome project. So many options. An engineering marvel (oops, restic has entered the chat … )

It’s already been asked :slight_smile: Add 'stdout-command' to 'dump' command · Issue #153 · creativeprojects/resticprofile · GitHub

It seems there is a pull request for that already.


How to correctly type group-by: '' in yaml?

Sorry, I realise this is a bug introduced in version 0.21.0
You should be able to use resticprofile version 0.20.0 with a flag group-by: ''

1 Like