self-hosting/profiles/db.nix

35 lines
1.1 KiB
Nix
Raw Normal View History

2021-11-25 00:59:46 +01:00
{ config, lib, pkgs, ... }:
{
imports = [
../environment.nix
../hardware/hcloud.nix
../modules/openssh.nix
../modules/postgresql.nix
../modules/custom-backup-job.nix
2021-12-27 05:28:51 +01:00
../modules/custom-monit.nix
2022-09-15 21:42:58 +02:00
../modules/monitoring-exporters.nix
2021-11-25 00:59:46 +01:00
];
2022-09-15 21:42:58 +02:00
networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ config.services.prometheus.exporters.node.port config.services.postgresql.port ];
2021-11-25 00:59:46 +01:00
2021-11-29 02:04:29 +01:00
sops.secrets = {
borgSshKey = {
owner = config.services.borgbackup.jobs.data.user;
key = "borg/client_keys/db1/private";
};
};
2021-11-25 00:59:46 +01:00
services.custom-backup-job = {
2021-12-27 05:28:51 +01:00
readWritePaths = [ "/nix/var/data/postgresql" "/nix/var/data/backup/" ];
2021-11-29 02:04:29 +01:00
preHook = ''
2021-11-25 00:59:46 +01:00
${pkgs.postgresql_12}/bin/pg_dump -U synapse synapse > /nix/var/data/postgresql/synapse.dmp
${pkgs.postgresql_12}/bin/pg_dump -U nextcloud nextcloud > /nix/var/data/postgresql/nextcloud.dmp
2021-12-27 16:39:22 +01:00
${pkgs.postgresql_12}/bin/pg_dump -U roundcube roundcube > /nix/var/data/postgresql/roundcube.dmp
2021-11-25 00:59:46 +01:00
'';
2021-12-27 05:28:51 +01:00
postHook = "touch /nix/var/data/backup/backup-ok";
2021-11-25 00:59:46 +01:00
startAt = "03:00";
2021-11-29 02:04:29 +01:00
sshKey = config.sops.secrets.borgSshKey.path;
2021-11-25 00:59:46 +01:00
};
}