self-hosting/profiles/db.nix

32 lines
878 B
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
];
networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ 5432 ];
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-11-29 02:04:29 +01:00
readWritePaths = [ "/nix/var/data/postgresql" ];
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
'';
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
};
networking.firewall.interfaces."ens10".allowedTCPPorts = [ 80 ];
}