diff --git a/flake.nix b/flake.nix index 780bfd6..17dbeab 100644 --- a/flake.nix +++ b/flake.nix @@ -27,10 +27,16 @@ system = "x86_64-linux"; modules = common.modules ++ [ ./modules/postgresql.nix + ./modules/custom-backup-job.nix ({ networking.hostName = "db1"; networking.domain = "banditlair.com"; networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ 5432 ]; + services.custom-backup-job = { + additionalReadWritePaths = [ "/nix/var/data/postgresql" ]; + additionalPreHook = "${pkgs.postgresql_12}/bin/pg_dump -U synapse synapse > /nix/var/data/postgresql/synapse.dmp"; + startAt = "03:00"; + }; }) ]; }; @@ -39,11 +45,17 @@ modules = common.modules ++ [ ./modules/murmur.nix ./modules/synapse.nix + ./modules/custom-backup-job.nix ({ networking.hostName = "backend1"; networking.domain = "banditlair.com"; networking.firewall.allowedTCPPorts = [ 80 443 64738 ]; networking.firewall.allowedUDPPorts = [ 64738 ]; + services.custom-backup-job = { + additionalReadWritePaths = [ "/nix/var/data/murmur" ]; + additionalPreHook = "cp /var/lib/murmur/murmur.sqlite /nix/var/data/murmur/murmur.sqlite"; + startAt = "03:30"; + }; }) ]; }; diff --git a/instances.tf b/instances.tf index 0dcefa1..a9a67e4 100644 --- a/instances.tf +++ b/instances.tf @@ -53,13 +53,15 @@ module "deploy_nixos_db1" { target_host = hcloud_server.db1.ipv4_address ssh_agent = true keys = { - "postgres-init.sql" = <