added healthcheck and backupInterval to podman-postgresql

This commit is contained in:
mc-fucker 2023-06-26 15:39:45 +02:00
parent 8c67608e95
commit 55107444ab

View file

@ -54,6 +54,13 @@ in
default = "/var/backup/postgresql"; default = "/var/backup/postgresql";
}; };
backupInterval = mkOption {
description = "The interval to backup the database";
type = types.str;
default = "hourly";
example = "daily";
};
}; };
})); }));
}; };
@ -74,7 +81,10 @@ in
"/var/lib/postgresql/${cfg.database}:/var/lib/postgresql/data" "/var/lib/postgresql/${cfg.database}:/var/lib/postgresql/data"
"${cfg.passwordFile}:${cfg.passwordFile}" "${cfg.passwordFile}:${cfg.passwordFile}"
]; ];
extraOptions = conf.podman.extraOptions; extraOptions = conf.podman.extraOptions ++ [
"--health-cmd=pg_isready -d ${cfg.database} -U ${cfg.user}"
"--health-start-period=10s"
];
}; };
}) cfgs); }) cfgs);
@ -96,7 +106,7 @@ in
}; };
timers."podman-postgresql-${cfg.database}-backup" = { timers."podman-postgresql-${cfg.database}-backup" = {
timerConfig = { timerConfig = {
OnCalendar = "hourly"; OnCalendar = cfg.backupInterval;
}; };
wantedBy = [ "podman-postgresql-${cfg.database}.service" ]; wantedBy = [ "podman-postgresql-${cfg.database}.service" ];
}; };