refactor: small backup refactoring

This commit is contained in:
Benjamin Bädorf 2023-11-05 23:47:06 +01:00 committed by b12f
parent 42fbde31e5
commit 841757517f
Signed by: pub.solar gitea
GPG key ID: F0332B04B7054873
7 changed files with 51 additions and 24 deletions

View file

@ -108,11 +108,19 @@
GPG_TTY = "$(tty)";
};
services.restic.backups.forgejo = flake.self.lib.droppieBackup {
services.restic.backups.forgejo = {
paths = [
"/var/lib/forgejo"
"/tmp/forgejo-backup.sql"
];
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
backupPrepareCommand = ''
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d gitea > /tmp/forgejo-backup.sql
'';

View file

@ -47,10 +47,18 @@
};
};
services.restic.backups.keycloak = flake.self.lib.droppieBackup {
services.restic.backups.keycloak = {
paths = [
"/tmp/keycloak-backup.sql"
];
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
backupPrepareCommand = ''
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d keycloak > /tmp/keycloak-backup.sql
'';

View file

@ -80,11 +80,19 @@
# ])
#'';
services.restic.backups.mailman = flake.self.lib.droppieBackup {
services.restic.backups.mailman = {
paths = [
"/var/lib/mailman"
"/var/lib/mailman-web/mailman-web.db"
"/var/lib/postfix/conf/aliases.db"
];
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
};
}

View file

@ -1,10 +1,6 @@
{ config, pkgs, flake, inputs, ... }:
{
config,
pkgs,
flake,
inputs,
...
}: {
age.secrets."mastodon-secret-key-base" = {
file = "${flake.self}/secrets/mastodon-secret-key-base.age";
mode = "400";
@ -98,12 +94,20 @@
};
};
services.restic.backups.mastodon = flake.self.lib.droppieBackup {
services.restic.backups.mastodon = {
paths = [
"/tmp/mastodon-backup.sql"
];
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
backupPrepareCommand = ''
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d gitea > /tmp/mastodon-backup.sql
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d mastodon > /tmp/mastodon-backup.sql
'';
backupCleanupCommand = ''
rm /tmp/mastodon-backup.sql

View file

@ -3,7 +3,8 @@
pkgs,
flake,
...
}: {
}:
{
age.secrets."nextcloud-secrets" = {
file = "${flake.self}/secrets/nextcloud-secrets.age";
mode = "400";
@ -130,11 +131,19 @@
database.createLocally = true;
};
services.restic.backups.nextcloud = flake.self.lib.droppieBackup {
services.restic.backups.nextcloud = {
paths = [
"/var/lib/nextcloud/data"
"/tmp/nextcloud-backup.sql"
];
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
backupPrepareCommand = ''
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d nextcloud > /tmp/nextcloud-backup.sql
'';

View file

@ -1,7 +1,7 @@
{ self, lib, inputs, ... }: {
# Configuration common to all Linux systems
flake = {
pub-solar.lib = let
lib = let
callLibs = file: import file {inherit lib;};
in rec {
## Define your own library functions here!

View file

@ -1,10 +0,0 @@
{ config, ... }: extraOptions: {
timerConfig = {
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
# droppie will be offline if nachtigall misses the timer
Persistent = false;
};
initialize = true;
passwordFile = config.age.secrets."restic-repo-droppie".path;
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
} // extraOptions