Configuration file

  • A configuration is a set of profiles.
  • Each profile is in a new section that has the name of the profile.
  • Inside each profile, you can specify different flags for each command.
  • A command definition is in a subsection of the name of the command.
[profile_name]

  [profile_name.backup]
profile_name:

  backup:
profile_name {

    backup = {

    }
}
{
  "profile_name": {
    "backup": {

    }
  }
}

All the restic flags can be defined in a section. For most of them you just need to remove the two dashes in front.

To set the flag --password-file, the name of the parameter is simply password-file.

There’s one exception: the flag --repo is named repository in the configuration

Example

So let’s say you normally use this simple command:

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

For resticprofile to generate this command automatically for you, here’s the configuration file:

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

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

  [default.backup]
    verbose = true
    source = [ "/home" ]
version: "1"

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

  backup:
    verbose: true
    source:
    - "/home"
default {
    repository = "local:/backup"
    password-file = "password.txt"

    backup = {
        verbose = true
        source = [ "/home" ]
    }
}
{
  "version": "1",
  "default": {
    "repository": "local:/backup",
    "password-file": "password.txt",
    "backup": {
      "verbose": true,
      "source": [
        "/home"
      ]
    }
  }
}

You may have noticed the source flag is accepting an array of values (inside brackets in TOML, list of values in YAML)

Now, assuming this configuration file is named profiles.conf in the current folder (it’s the default config file name), you can simply run

resticprofile backup

and resticprofile will do its magic and generate the command line for you.

If you have any doubt on what it’s running, you can try a --dry-run:

resticprofile --dry-run backup
2022/05/18 17:14:07 profile 'default': starting 'backup'
2022/05/18 17:14:07 dry-run: /usr/bin/restic backup --password-file password.txt --repo local:/backup --verbose /home
2022/05/18 17:14:07 profile 'default': finished 'backup'

More information