nixpkgs/nixos/modules/services/backup
Elias Probst 27da11972d nixos/restic: correct location of cache directory
By default, restic determines the location of the cache based on the XDG
base dir specification, which is `~/.cache/restic` when the environment
variable `$XDG_CACHE_HOME` isn't set.
As restic is executed as root by default, this resulted in the cache being
written to `/root/.cache/restic`, which is not quite right for a system
service and also meant, multiple backup services would use the same cache
directory - potentially causing issues with locking, data corruption,
etc.

The goal was to ensure, restic uses the correct cache location for a
system service - one cache per backup specification, using `/var/cache`
as the base directory for it.

systemd sets the environment variable `$CACHE_DIRECTORY` once
`CacheDirectory=` is defined, but restic doesn't change its behavior
based on the presence of this environment variable.
Instead, the specifier [1] `%C` can be used to point restic explicitly
towards the correct cache location using the `--cache-dir` argument.

Furthermore, the `CacheDirectoryMode=` was set to `0700`, as the default
of `0755` is far too open in this case, as the cache might contain
sensitive data.

[1] https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers
2021-01-30 18:24:51 -08:00
..
automysqlbackup.nix
bacula.nix bacula: add types 2021-01-25 19:00:01 +01:00
borgbackup.nix
borgbackup.xml nixos/doc: Improve code listings 2020-09-23 01:25:25 +02:00
duplicati.nix
duplicity.nix
mysql-backup.nix
postgresql-backup.nix
postgresql-wal-receiver.nix
restic-rest-server.nix
restic.nix nixos/restic: correct location of cache directory 2021-01-30 18:24:51 -08:00
rsnapshot.nix
sanoid.nix
syncoid.nix Merge pull request #79759 from lopsided98/syncoid-no-root 2020-10-25 10:40:33 -04:00
tarsnap.nix treewide: fix double quoted strings in meta.description 2021-01-24 19:56:59 +07:00
tsm.nix
zfs-replication.nix
znapzend.nix