Jump to content

Restic: Difference between revisions

From NixOS Wiki
Klinger (talk | contribs)
Expand intro and add configuration options
Line 1: Line 1:
[https://restic.net/ Restic] is a fast and secure backup program.
[https://restic.net/ Restic] is a fast and secure backup program. NixOS packages both <code>restic</code> client (program used to make backups) and <code>restic-rest-server</code> (one of the backends to store the backups remotely, "repository" in restic parlance).


== Installing ==
== Installing ==


Add <code>restic</code> to <code>environment.systemPackages</code> like so:
If you want to manually create restic backups, add <code>restic</code> to <code>environment.systemPackages</code> like so:


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
Line 10: Line 10:
];
];
</syntaxHighlight>
</syntaxHighlight>
== Configuring ==
=== Restic ===
NixOS provides options to create a systemd timer and a service that will create the backups. See [https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=services.restic.backups services.restic.backups options].
=== Restic Rest Server ===
Restic Rest Server is one of the options for a remote repository<ref>https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#rest-server</ref>. It can be installed by enabling the <code>services.restic.server.enable</code> option. By default the server requires either providing it with <code>htpasswd</code> file or running it without authentication. If provided, the username and password pairs <code>htpassd</code> file will be used to authenticate the restic clients connecting to the server. To run the server without authentication, you can pass the flag using the <code>extraFlags</code> option like this: <code>services.restic.server.extraFlags = [ "--no-auth" ];</code>
Passing the <code>htpasswd</code> file should be done using one of the [[Comparison of secret managing schemes|secret management methods]].


== Security Wrapper ==
== Security Wrapper ==

Revision as of 01:09, 12 February 2025

Restic is a fast and secure backup program. NixOS packages both restic client (program used to make backups) and restic-rest-server (one of the backends to store the backups remotely, "repository" in restic parlance).

Installing

If you want to manually create restic backups, add restic to environment.systemPackages like so:

environment.systemPackages = with pkgs; [
  restic
];

Configuring

Restic

NixOS provides options to create a systemd timer and a service that will create the backups. See services.restic.backups options.

Restic Rest Server

Restic Rest Server is one of the options for a remote repository[1]. It can be installed by enabling the services.restic.server.enable option. By default the server requires either providing it with htpasswd file or running it without authentication. If provided, the username and password pairs htpassd file will be used to authenticate the restic clients connecting to the server. To run the server without authentication, you can pass the flag using the extraFlags option like this: services.restic.server.extraFlags = [ "--no-auth" ];

Passing the htpasswd file should be done using one of the secret management methods.

Security Wrapper

If you want to back up your system without running restic as root, you can create a user and security wrapper to give restic the capability to read anything on the filesystem as if it were running as root. The following will create the wrapper at /run/wrappers/bin/restic

users.users.restic = {
  isNormalUser = true;
};

security.wrappers.restic = {
  source = "${pkgs.restic.out}/bin/restic";
  owner = "restic";
  group = "users";
  permissions = "u=rwx,g=,o=";
  capabilities = "cap_dac_read_search=+ep";
};