mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2026-02-04 09:10:01 +01:00
bicep/{postgres,mysql}: split config into several files
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
./services/calendar-bot.nix
|
./services/calendar-bot.nix
|
||||||
#./services/git-mirrors
|
#./services/git-mirrors
|
||||||
./services/minecraft-heatmap.nix
|
./services/minecraft-heatmap.nix
|
||||||
./services/mysql.nix
|
./services/mysql
|
||||||
./services/postgres.nix
|
./services/postgresql
|
||||||
|
|
||||||
./services/matrix
|
./services/matrix
|
||||||
];
|
];
|
||||||
|
|||||||
26
hosts/bicep/services/mysql/backup.nix
Normal file
26
hosts/bicep/services/mysql/backup.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.services.mysql;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.mysqlBackup = lib.mkIf cfg.enable {
|
||||||
|
enable = true;
|
||||||
|
location = "/var/lib/mysql-backups";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.rsync-pull-targets = lib.mkIf cfg.enable {
|
||||||
|
enable = true;
|
||||||
|
locations.${config.services.mysqlBackup.location} = {
|
||||||
|
user = "root";
|
||||||
|
rrsyncArgs.ro = true;
|
||||||
|
authorizedKeysAttrs = [
|
||||||
|
"restrict"
|
||||||
|
"no-agent-forwarding"
|
||||||
|
"no-port-forwarding"
|
||||||
|
"no-pty"
|
||||||
|
"no-X11-forwarding"
|
||||||
|
];
|
||||||
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJgj55/7Cnj4cYMJ5sIkl+OwcGeBe039kXJTOf2wvo9j mysql rsync backup";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ let
|
|||||||
dataDir = "/data/mysql";
|
dataDir = "/data/mysql";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ ./backup.nix ];
|
||||||
|
|
||||||
sops.secrets."mysql/password" = {
|
sops.secrets."mysql/password" = {
|
||||||
owner = "mysql";
|
owner = "mysql";
|
||||||
group = "mysql";
|
group = "mysql";
|
||||||
@@ -42,27 +44,6 @@ in
|
|||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.mysqlBackup = lib.mkIf cfg.enable {
|
|
||||||
enable = true;
|
|
||||||
location = "/var/lib/mysql-backups";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.rsync-pull-targets = lib.mkIf cfg.enable {
|
|
||||||
enable = true;
|
|
||||||
locations.${config.services.mysqlBackup.location} = {
|
|
||||||
user = "root";
|
|
||||||
rrsyncArgs.ro = true;
|
|
||||||
authorizedKeysAttrs = [
|
|
||||||
"restrict"
|
|
||||||
"no-agent-forwarding"
|
|
||||||
"no-port-forwarding"
|
|
||||||
"no-pty"
|
|
||||||
"no-X11-forwarding"
|
|
||||||
];
|
|
||||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJgj55/7Cnj4cYMJ5sIkl+OwcGeBe039kXJTOf2wvo9j mysql rsync backup";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg.enable [ 3306 ];
|
networking.firewall.allowedTCPPorts = lib.mkIf cfg.enable [ 3306 ];
|
||||||
|
|
||||||
systemd.tmpfiles.settings."10-mysql".${dataDir}.d = lib.mkIf cfg.enable {
|
systemd.tmpfiles.settings."10-mysql".${dataDir}.d = lib.mkIf cfg.enable {
|
||||||
27
hosts/bicep/services/postgresql/backup.nix
Normal file
27
hosts/bicep/services/postgresql/backup.nix
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.services.postgresql;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.postgresqlBackup = lib.mkIf cfg.enable {
|
||||||
|
enable = true;
|
||||||
|
location = "/var/lib/postgres-backups";
|
||||||
|
backupAll = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.rsync-pull-targets = lib.mkIf cfg.enable {
|
||||||
|
enable = true;
|
||||||
|
locations.${config.services.postgresqlBackup.location} = {
|
||||||
|
user = "root";
|
||||||
|
rrsyncArgs.ro = true;
|
||||||
|
authorizedKeysAttrs = [
|
||||||
|
"restrict"
|
||||||
|
"no-agent-forwarding"
|
||||||
|
"no-port-forwarding"
|
||||||
|
"no-pty"
|
||||||
|
"no-X11-forwarding"
|
||||||
|
];
|
||||||
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGvO7QX7QmwSiGLXEsaxPIOpAqnJP3M+qqQRe5dzf8gJ postgresql rsync backup";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ let
|
|||||||
cfg = config.services.postgresql;
|
cfg = config.services.postgresql;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ ./backup.nix ];
|
||||||
|
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_18;
|
package = pkgs.postgresql_18;
|
||||||
@@ -121,26 +123,4 @@ in
|
|||||||
|
|
||||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg.enable [ 5432 ];
|
networking.firewall.allowedTCPPorts = lib.mkIf cfg.enable [ 5432 ];
|
||||||
networking.firewall.allowedUDPPorts = lib.mkIf cfg.enable [ 5432 ];
|
networking.firewall.allowedUDPPorts = lib.mkIf cfg.enable [ 5432 ];
|
||||||
|
|
||||||
services.postgresqlBackup = lib.mkIf cfg.enable {
|
|
||||||
enable = true;
|
|
||||||
location = "/var/lib/postgres-backups";
|
|
||||||
backupAll = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.rsync-pull-targets = lib.mkIf cfg.enable {
|
|
||||||
enable = true;
|
|
||||||
locations.${config.services.postgresqlBackup.location} = {
|
|
||||||
user = "root";
|
|
||||||
rrsyncArgs.ro = true;
|
|
||||||
authorizedKeysAttrs = [
|
|
||||||
"restrict"
|
|
||||||
"no-agent-forwarding"
|
|
||||||
"no-port-forwarding"
|
|
||||||
"no-pty"
|
|
||||||
"no-X11-forwarding"
|
|
||||||
];
|
|
||||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGvO7QX7QmwSiGLXEsaxPIOpAqnJP3M+qqQRe5dzf8gJ postgresql rsync backup";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user