postgresql-backup: move to own services

This way the `startAt` setting is only set once.
This commit is contained in:
Antoine Martin 2021-01-30 22:15:33 +01:00
parent 297eb0a6f9
commit 253530ea6f
5 changed files with 28 additions and 5 deletions

View file

@ -94,6 +94,10 @@
useACME = true; useACME = true;
domain = "monitoring.${config.networking.domain}"; domain = "monitoring.${config.networking.domain}";
}; };
postgresql-backup = {
enable = true;
};
}; };
security.acme.acceptTerms = true; security.acme.acceptTerms = true;

View file

@ -6,5 +6,6 @@
./matrix.nix ./matrix.nix
./miniflux.nix ./miniflux.nix
./monitoring.nix ./monitoring.nix
./postgresql-backup.nix
]; ];
} }

View file

@ -13,6 +13,7 @@ with lib;
let let
cfg = config.my.services.matrix; cfg = config.my.services.matrix;
my = config.my;
federationPort = { public = 8448; private = 11338; }; federationPort = { public = 8448; private = 11338; };
clientPort = { public = 443; private = 11339; }; clientPort = { public = 443; private = 11339; };
@ -28,11 +29,8 @@ in {
package = pkgs.postgresql_12; package = pkgs.postgresql_12;
}; };
services.postgresqlBackup = { services.postgresqlBackup = mkIf my.services.postgresql-backup.enable {
enable = true;
databases = [ "matrix-synapse" ]; databases = [ "matrix-synapse" ];
# Borg backup starts at midnight so create DB dump just before
startAt = "*-*-* 23:30:00";
}; };
services.matrix-synapse = { services.matrix-synapse = {

View file

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.my.services.miniflux; cfg = config.my.services.miniflux;
my = config.my;
domain = config.networking.domain; domain = config.networking.domain;
in { in {
@ -28,7 +29,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
# services.postgresql is automatically enabled by services.miniflux, let's # services.postgresql is automatically enabled by services.miniflux, let's
# back it up # back it up
services.postgresqlBackup = { services.postgresqlBackup = mkIf my.services.postgresql-backup.enable {
databases = [ "miniflux" ]; databases = [ "miniflux" ];
}; };

View file

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.my.services.postgresql-backup;
in {
options.my.services.postgresql-backup = {
enable = mkEnableOption "Backup SQL databases";
};
config = mkIf cfg.enable {
services.postgresqlBackup = {
enable = true;
# Borg backup starts at midnight so create DB dump just before
startAt = "*-*-* 23:30:00";
};
};
}