nixfiles/hosts/hetzner-arm/containers/mail/profiles/restic.nix
2024-03-09 22:18:26 +00:00

40 lines
1 KiB
Nix

{
self,
pkgs,
config,
...
}: let
backupSchedules = import "${self}/data/backupSchedules.nix";
secrets = config.services.secrets.secrets;
mailConfig = config.services.mailserver;
in {
environment.systemPackages = with pkgs; [
restic
(pkgs.writeShellScriptBin "restic-mail" ''
env \
RESTIC_PASSWORD_FILE=${secrets.restic_password.path} \
$(cat ${secrets.restic_env.path}) \
${pkgs.restic}/bin/restic $@
'')
];
services.restic.backups.mail = {
user = "root";
paths = [
mailConfig.vmail.directory
mailConfig.sieveDirectory
mailConfig.dkim.directory
];
# repository is overrided in environmentFile to contain auth
# make sure to keep up to date when changing repository
repository = "rest:https://storage-restic.owo.monster/Mail";
passwordFile = "${secrets.restic_password.path}";
environmentFile = "${secrets.restic_env.path}";
pruneOpts = ["--keep-last 60"];
timerConfig = backupSchedules.restic.medium;
};
}