backups: matrix: split into module
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Jake Hillion 2023-04-29 13:22:10 +01:00
parent e0cdd07733
commit f05bb1ff02
4 changed files with 60 additions and 30 deletions

View File

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./matrix.nix
];
}

View File

@ -0,0 +1,50 @@
{ config, pkgs, lib, ... }:
let
cfg = config.custom.backups.matrix;
in
{
options.custom.backups.matrix = {
enable = lib.mkEnableOption "matrix";
};
config = lib.mkIf cfg.enable {
age.secrets = {
"backblaze/vm-strangervm-backups-matrix" = {
file = ../../secrets/backblaze/vm-strangervm-backups-matrix.age;
};
"restic/b2-backups-matrix" = {
file = ../../secrets/restic/b2-backups-matrix.age;
};
};
services = {
postgresqlBackup = {
enable = true;
compression = "none"; # for better diffing
databases = [ "matrix-synapse" ];
};
restic.backups."matrix" = {
user = "root";
timerConfig = {
OnCalendar = "03:00";
RandomizedDelaySec = "30m";
};
repository = "b2:hillion-personal:backups/matrix";
pruneOpts = [
"--keep-daily 14"
"--keep-weekly 5"
"--keep-monthly 24"
"--keep-yearly 10"
];
passwordFile = config.age.secrets."restic/b2-backups-matrix".path;
environmentFile = config.age.secrets."backblaze/vm-strangervm-backups-matrix".path;
paths = [
"${config.services.postgresqlBackup.location}/matrix-synapse.sql"
config.services.matrix-synapse.dataDir
];
};
};
};
}

View File

@ -2,6 +2,7 @@
{
imports = [
./backups/default.nix
./desktop/awesome/default.nix
./resilio.nix
./tailscale.nix

View File

@ -1,6 +1,8 @@
{ config, pkgs, lib, ... }:
{
config.custom.backups.matrix.enable = true;
## Matrix (matrix.hillion.co.uk)
config.age.secrets."matrix/matrix.hillion.co.uk/macaroon_secret_key" = {
file = ../../secrets/matrix/matrix.hillion.co.uk/macaroon_secret_key.age;
@ -12,14 +14,6 @@
owner = "matrix-synapse";
group = "matrix-synapse";
};
config.age.secrets."backblaze/vm-strangervm-backups-matrix" = {
file = ../../secrets/backblaze/vm-strangervm-backups-matrix.age;
};
config.age.secrets."restic/b2-backups-matrix" = {
file = ../../secrets/restic/b2-backups-matrix.age;
owner = "postgres";
group = "postgres";
};
config.services.postgresql = {
enable = true;
@ -31,28 +25,6 @@
LC_CTYPE = "C";
'';
};
config.services.postgresqlBackup = {
enable = true;
compression = "none"; # for better diffing
databases = [ "matrix-synapse" ];
};
config.services.restic.backups."matrix" = {
user = "postgres";
timerConfig = {
OnCalendar = "03:00";
RandomizedDelaySec = "30m";
};
repository = "b2:hillion-personal:backups/matrix";
pruneOpts = [
"--keep-daily 14"
"--keep-weekly 5"
"--keep-monthly 24"
"--keep-yearly 10"
];
paths = [ "${config.services.postgresqlBackup.location}/matrix-synapse.sql" ];
passwordFile = config.age.secrets."restic/b2-backups-matrix".path;
environmentFile = config.age.secrets."backblaze/vm-strangervm-backups-matrix".path;
};
config.services.matrix-synapse = {
enable = true;