Create backups from database dump & update about page #4

Merged
emily merged 2 commits from mikael/nixfiles-emily:main into main 2024-11-09 23:10:40 +01:00
2 changed files with 30 additions and 3 deletions
Showing only changes of commit aaf77b9ca9 - Show all commits

View file

@ -1,4 +1,4 @@
{ lib, ... }: { { lib, config, ... }: {
imports = [ imports = [
../../common ../../common
../../profiles/headless.nix ../../profiles/headless.nix
@ -13,7 +13,9 @@
}; };
kyouma.nginx.defaultForbidden = "florp.social"; kyouma.nginx.defaultForbidden = "florp.social";
kyouma.restic = { kyouma.restic = let
pgBackup = "/var/cache/postgresql.sql";
in {
enable = true; enable = true;
remoteUser = "zh3485s1"; remoteUser = "zh3485s1";
timerConfig = { timerConfig = {
@ -22,9 +24,21 @@
}; };
paths = [ paths = [
"/var/lib/akkoma" "/var/lib/akkoma"
"/var/lib/postgresql"
"/var/lib/secrets" "/var/lib/secrets"
pgBackup
]; ];
backupPrepareCommand = ''
umask 0077
rm -f -- ${pgBackup}
${lib.getExe' config.services.postgresql.package "pg_dumpall"} \
-U ${config.services.postgresql.superUser} \
-f ${pgBackup}
'';
backupCleanupCommand = ''
rm -f -- ${pgBackup}
'';
}; };
systemd.network.networks."98-eth-default" = { systemd.network.networks."98-eth-default" = {
address = [ address = [

View file

@ -48,6 +48,19 @@ in {
Persistent = true; Persistent = true;
}; };
}; };
# FIXME: Can these be just inherited?
backupPrepareCommand = mkOption {
description = "preparation script";
type = with types; nullOr str;
default = null;
};
backupCleanupCommand = mkOption {
description = "cleanup script";
type = with types; nullOr str;
default = null;
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
sops.secrets."restic/${cfg.remoteUser}/password" = { sops.secrets."restic/${cfg.remoteUser}/password" = {