2022-12-04 13:45:43 +00:00
|
|
|
{
|
2024-03-09 22:18:26 +00:00
|
|
|
self,
|
2022-12-04 13:45:43 +00:00
|
|
|
pkgs,
|
2023-08-09 15:11:04 +01:00
|
|
|
config,
|
2022-12-04 13:45:43 +00:00
|
|
|
...
|
|
|
|
}: let
|
2024-03-09 22:18:26 +00:00
|
|
|
backupSchedules = import "${self}/data/backupSchedules.nix";
|
2024-03-10 17:26:18 +00:00
|
|
|
inherit (config.services.secrets) secrets;
|
2023-09-21 05:06:27 +01:00
|
|
|
|
2023-09-18 03:56:58 +01:00
|
|
|
mailConfig = config.services.mailserver;
|
2022-11-02 11:32:03 +00:00
|
|
|
in {
|
2023-08-01 19:48:37 +01:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
restic
|
2023-08-09 15:11:04 +01:00
|
|
|
(pkgs.writeShellScriptBin "restic-mail" ''
|
2022-11-02 11:32:03 +00:00
|
|
|
env \
|
2023-09-21 05:06:27 +01:00
|
|
|
RESTIC_PASSWORD_FILE=${secrets.restic_password.path} \
|
|
|
|
$(cat ${secrets.restic_env.path}) \
|
2022-11-02 11:32:03 +00:00
|
|
|
${pkgs.restic}/bin/restic $@
|
|
|
|
'')
|
|
|
|
];
|
2022-08-04 21:53:51 +01:00
|
|
|
|
2023-08-09 15:11:04 +01:00
|
|
|
services.restic.backups.mail = {
|
2022-11-02 11:32:03 +00:00
|
|
|
user = "root";
|
|
|
|
paths = [
|
2023-09-18 03:56:58 +01:00
|
|
|
mailConfig.vmail.directory
|
|
|
|
mailConfig.sieveDirectory
|
|
|
|
mailConfig.dkim.directory
|
2022-11-02 11:32:03 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# repository is overrided in environmentFile to contain auth
|
|
|
|
# make sure to keep up to date when changing repository
|
2023-08-09 15:11:04 +01:00
|
|
|
repository = "rest:https://storage-restic.owo.monster/Mail";
|
2023-09-21 05:06:27 +01:00
|
|
|
passwordFile = "${secrets.restic_password.path}";
|
|
|
|
environmentFile = "${secrets.restic_env.path}";
|
2022-11-02 11:32:03 +00:00
|
|
|
|
2024-03-09 22:18:26 +00:00
|
|
|
pruneOpts = ["--keep-last 60"];
|
|
|
|
timerConfig = backupSchedules.restic.medium;
|
2022-08-04 21:53:51 +01:00
|
|
|
};
|
2021-12-29 13:17:01 +00:00
|
|
|
}
|