nixfiles/hosts/hetzner-arm/containers/mail/profiles/restic.nix

63 lines
1.4 KiB
Nix
Raw Normal View History

{
pkgs,
2023-08-09 15:11:04 +01:00
config,
...
}: let
secrets = config.services.secrets.secrets;
2023-09-18 03:56:58 +01:00
mailConfig = config.services.mailserver;
2022-08-12 17:06:50 +01:00
backupPrepareCommand = "${
(pkgs.writeShellScriptBin "backupPrepareCommand" ''
2023-08-09 15:11:04 +01:00
systemctl start postgresqlBackup-roundcube --wait
'')
}/bin/backupPrepareCommand";
2022-11-02 11:32:03 +00:00
in {
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 \
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 = [
"/var/backup/postgresql"
2022-08-04 16:58:49 +01:00
2023-09-18 03:56:58 +01:00
mailConfig.vmail.directory
mailConfig.sieveDirectory
mailConfig.dkim.directory
2022-11-02 11:32:03 +00:00
"/var/lib/redis-rspamd"
];
# 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";
passwordFile = "${secrets.restic_password.path}";
environmentFile = "${secrets.restic_env.path}";
2022-11-02 11:32:03 +00:00
pruneOpts = [
2023-09-30 16:49:52 +01:00
"--keep-last 100"
];
2022-11-02 11:32:03 +00:00
timerConfig = {
OnBootSec = "1m";
2023-09-30 16:49:52 +01:00
OnCalendar = "8h";
2022-11-02 11:32:03 +00:00
};
inherit backupPrepareCommand;
};
2022-08-04 21:53:51 +01:00
2023-08-09 15:11:04 +01:00
services.postgresql.enable = true;
2022-08-04 21:53:51 +01:00
services.postgresqlBackup = {
enable = true;
backupAll = false;
2023-08-09 15:11:04 +01:00
databases = ["roundcube"];
2022-08-04 21:53:51 +01:00
compression = "zstd";
};
2021-12-29 13:17:01 +00:00
}