Skip to content

Commit

Permalink
build03, web02: backup postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Nov 18, 2024
1 parent 06c99f6 commit 6211657
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
26 changes: 25 additions & 1 deletion hosts/build03/postgresql.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
{ pkgs, ... }:
{
config,
inputs,
pkgs,
...
}:

{
imports = [
inputs.self.nixosModules.backup
];

services.postgresqlBackup = {
enable = true;
compression = "none";
startAt = "daily";
};

nixCommunity.backup = [
{
name = "postgresql";
after = [ config.systemd.services.postgresqlBackup.name ];
paths = [ config.services.postgresqlBackup.location ];
startAt = "daily";
}
];

services.postgresql.ensureUsers = [ { name = "telegraf"; } ];

systemd.services.postgresql.postStart = ''
Expand Down
1 change: 1 addition & 0 deletions hosts/web02/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
imports = [
./gandi.nix
./postgresql.nix
inputs.self.nixosModules.monitoring
inputs.self.nixosModules.nginx
];
Expand Down
31 changes: 31 additions & 0 deletions hosts/web02/postgresql.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
config,
inputs,
pkgs,
...
}:
{
imports = [
inputs.self.nixosModules.backup
];

services.postgresqlBackup = {
enable = true;
compression = "none";
startAt = "daily";
};

nixCommunity.backup = [
{
name = "postgresql";
after = [ config.systemd.services.postgresqlBackup.name ];
paths = [ config.services.postgresqlBackup.location ];
startAt = "daily";
}
];

services.postgresql = {
enable = true;
package = pkgs.postgresql_17;
};
}
1 change: 1 addition & 0 deletions modules/nixos/monitoring/alert-rules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(lib.genAttrs
[
"borgbackup-job-github-org.service"
"borgbackup-job-postgresql.service"
]
(name: {
expr = ''absent_over_time(task_last_run{name="${name}"}[1d])'';
Expand Down
9 changes: 1 addition & 8 deletions modules/nixos/monitoring/grafana.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
config,
inputs,
pkgs,
...
}:
{ config, inputs, ... }:
{
systemd.services.grafana.after = [ "prometheus.service" ];

Expand Down Expand Up @@ -68,8 +63,6 @@
];

services.postgresql = {
enable = true;
package = pkgs.postgresql_17;
ensureDatabases = [ "grafana" ];
ensureUsers = [
{
Expand Down
Binary file modified secrets/hetzner-borgbackup-ssh.age
Binary file not shown.

0 comments on commit 6211657

Please sign in to comment.