backups: matrix: split into module
This commit is contained in:
parent
e0cdd07733
commit
f05bb1ff02
7
modules/backups/default.nix
Normal file
7
modules/backups/default.nix
Normal file
@ -0,0 +1,7 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./matrix.nix
|
||||
];
|
||||
}
|
50
modules/backups/matrix.nix
Normal file
50
modules/backups/matrix.nix
Normal 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
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
./backups/default.nix
|
||||
./desktop/awesome/default.nix
|
||||
./resilio.nix
|
||||
./tailscale.nix
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user