services.restic.enable
Whether to enable restic.
Type: boolean
Default:
false
Example:
true
Declared by:
services.restic.backups
Backup configurations for Restic.
On Linux systems, a corresponding systemd user service (and optionally a systemd timer for automatic scheduling) will be created, along with a helper wrapper script.
On non-Linux platforms, only the helper wrapper script will be created.
Type: attribute set of (submodule)
Default:
{ }
Example:
{
localbackup = {
exclude = [
"/home/*/.cache"
];
initialize = true;
passwordFile = "/etc/nixos/secrets/restic-password";
paths = [
"/home"
];
repository = "/mnt/backup-hdd";
};
remotebackup = {
extraOptions = [
"sftp.command='ssh backup@host -i /etc/nixos/secrets/backup-private-key -s sftp'"
];
passwordFile = "/etc/nixos/secrets/restic-password";
paths = [
"/home"
];
repository = "sftp:backup@host:/backups/home";
timerConfig = {
OnCalendar = "00:05";
RandomizedDelaySec = "5h";
};
};
}
Declared by:
services.restic.backups.<name>.package
The restic package to use.
Type: package
Default:
pkgs.restic
Declared by:
services.restic.backups.<name>.backupCleanupCommand
A script that must run after finishing the backup process.
This option is only supported on linux.
Type: null or string
Default:
null
Declared by:
services.restic.backups.<name>.backupPrepareCommand
A script that must run before starting the backup process.
This option is only supported on linux.
Type: null or string
Default:
null
Declared by:
services.restic.backups.<name>.checkOpts
A list of options for ‘restic check’.
This option is only supported on linux.
Type: list of string
Default:
[ ]
Example:
[
"--with-cache"
]
Declared by:
services.restic.backups.<name>.createWrapper
Whether to generate and add a script to the system path, that has the same environment variables set as the systemd service. This can be used to e.g. mount snapshots or perform other opterations, without having to manually specify most options.
Type: boolean
Default:
true
Declared by:
services.restic.backups.<name>.dynamicFilesFrom
A script that produces a list of files to back up. The results of
this command, along with the paths specified via paths,
are given to the ‘–files-from’ option.
This option is only supported on linux.
Type: null or string
Default:
null
Example:
"find /home/alice/git -type d -name .git"
Declared by:
services.restic.backups.<name>.environmentFile
A file containing the credentials to access the repository, in the
format of an EnvironmentFile as described by systemd.exec(5).
See https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html
for the specific credentials you will need for your backend.
Type: null or string
Default:
null
Declared by:
services.restic.backups.<name>.exclude
Patterns to exclude when backing up. See https://restic.readthedocs.io/en/stable/040_backup.html#excluding-files for details on syntax.
This option is only supported on linux.
Type: list of string
Default:
[ ]
Example:
[
"/var/cache"
"/home/*/.cache"
".git"
]
Declared by:
services.restic.backups.<name>.extraBackupArgs
Extra arguments passed to restic backup.
This option is only supported on linux.
Type: list of string
Default:
[ ]
Example:
[
"--cleanup-cache"
"--exclude-file=/etc/nixos/restic-ignore"
]
Declared by:
services.restic.backups.<name>.extraOptions
Extra extended options to be passed to the restic -o flag. See the restic
documentation for more details.
Type: list of string
Default:
[ ]
Example:
[
"sftp.command='ssh backup@192.168.1.100 -i /home/user/.ssh/id_rsa -s sftp'"
]
Declared by:
services.restic.backups.<name>.inhibitsSleep
Prevents the system from sleeping while backing up. This uses systemd-inhibit
to block system idling so you may need to enable polkitd with
security.polkit.enable.
This option is only supported on linux.
Type: boolean
Default:
false
Example:
true
Declared by:
services.restic.backups.<name>.initialize
Create the repository if it does not already exist.
This option is only supported on linux.
Type: boolean
Default:
false
Declared by:
services.restic.backups.<name>.passwordCommand
Command which returns one of the repository’s passwords. Since
PATH is set in the systemd service you need to provide
the absolute path to the executable.
Type: null or string
Default:
null
Example:
"${lib.getExe pkgs.gopass} show backups"
Declared by:
services.restic.backups.<name>.passwordFile
A file containing the repository password.
Type: null or string
Default:
null
Example:
"/etc/nixos/restic-password"
Declared by:
services.restic.backups.<name>.paths
Paths to back up, alongside those defined by the dynamicFilesFrom
option. If left empty and dynamicFilesFrom is also not specified, no
backup command will be run. This can be used to create a prune-only job.
This option is only supported on linux.
Type: list of string
Default:
[ ]
Example:
[
"/var/lib/postgresql"
"/home/user/backup"
]
Declared by:
services.restic.backups.<name>.progressFps
Controls the frequency of progress reporting.
Type: null or (nonnegative integer or floating point number, meaning >=0)
Default:
null
Example:
0.1
Declared by:
services.restic.backups.<name>.pruneOpts
A list of policy options for ‘restic forget –prune’, to automatically prune old snapshots. See https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy for a full list of options.
Note: The ‘forget’ command is run after the ‘backup’ command, so keep that in mind when constructing the –keep-* options.
This option is only supported on linux.
Type: list of string
Default:
[ ]
Example:
[
"--keep-daily 7"
"--keep-weekly 5"
"--keep-monthly 12"
"--keep-yearly 75"
]
Declared by:
services.restic.backups.<name>.rcloneOptions
Options to pass to rclone to control its behavior. See
https://rclone.org/docs/#options for available options. When specifying
option names, strip the leading --. To set a flag such as
--drive-use-trash, which does not take a value, set the value to the
Boolean true.
Type: attribute set of (string or boolean or signed integer)
Default:
{ }
Example:
{
bwlimit = "10M";
drive-use-trash = true;
}
Declared by:
services.restic.backups.<name>.repository
Repository to backup to. This should be in the form of a backend specification as detailed here https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html.
If your using the rclone backend, you can configure your remotes with
programs.rclone.remotes then use them in your backend specification.
Type: null or string
Default:
null
Example:
"sftp:backup@192.168.1.100:/backups/‹name›"
Declared by:
services.restic.backups.<name>.repositoryFile
Path to a file containing the repository location to backup to. This should be
in the same form as the repository option.
Type: null or absolute path
Default:
null
Declared by:
services.restic.backups.<name>.runCheck
Whether to run ‘restic check’ with the provided checkOpts options.
This option is only supported on linux.
Type: boolean
Default:
lib.length config.checkOpts > 0 || lib.length config.pruneOpts > 0
Example:
true
Declared by:
services.restic.backups.<name>.ssh-package
The openssh package to use.
Type: package
Default:
pkgs.openssh
Declared by:
services.restic.backups.<name>.timerConfig
When to run the backup. See systemd.timer(5) for details. If null
no timer is created and the backup will only run when explicitly started.
This option is only supported on linux.
Type: null or (attribute set of (boolean or signed integer or string or absolute path or list of (boolean or signed integer or string or absolute path)))
Default:
{
OnCalendar = "daily";
Persistent = true;
}
Example:
{
OnCalendar = "00:05";
Persistent = true;
RandomizedDelaySec = "5h";
}
Declared by: