mirror of
https://github.com/RGBCube/ncc
synced 2025-07-30 11:37:44 +00:00
Back up postgresql
This commit is contained in:
parent
ccf0c5fee5
commit
2959c04419
1 changed files with 43 additions and 19 deletions
|
@ -1,29 +1,53 @@
|
||||||
{ config, lib, ... }: with lib;
|
{ config, lib, pkgs, ... }: with lib;
|
||||||
|
|
||||||
systemConfiguration {
|
systemConfiguration {
|
||||||
secrets.resticPassword.file = ./password.age;
|
secrets.resticPassword.file = ./password.age;
|
||||||
|
|
||||||
services.restic.backups.general = {
|
services.restic.backups = let
|
||||||
passwordFile = config.secrets.resticPassword.path;
|
defaultConfig = name: {
|
||||||
initialize = true;
|
repository = "sftp:backup@disk:${config.networking.hostName}-${name}";
|
||||||
|
passwordFile = config.secrets.resticPassword.path;
|
||||||
|
initialize = true;
|
||||||
|
|
||||||
repository = "sftp:backup@disk:${config.networking.hostName}-varlib";
|
pruneOpts = [
|
||||||
|
"--keep-daily 3"
|
||||||
|
"--keep-weekly 5"
|
||||||
|
"--keep-monthly 12"
|
||||||
|
"--keep-yearly 75"
|
||||||
|
];
|
||||||
|
|
||||||
paths = map (dir: "/var/lib/${dir}") [
|
timerConfig = {
|
||||||
"dkim"
|
OnCalendar = "daily";
|
||||||
"forgejo"
|
Persistent = true;
|
||||||
"gitea-runner"
|
};
|
||||||
"grafana"
|
};
|
||||||
"mail"
|
in {
|
||||||
"matrix-sliding-sync"
|
general = (defaultConfig "general") // {
|
||||||
"matrix-synapse"
|
paths = map (dir: "/var/lib/${dir}") [
|
||||||
"nextcloud"
|
"dkim"
|
||||||
"postfix"
|
"forgejo"
|
||||||
];
|
"gitea-runner"
|
||||||
|
"grafana"
|
||||||
|
"mail"
|
||||||
|
"matrix-sliding-sync"
|
||||||
|
"matrix-synapse"
|
||||||
|
"nextcloud"
|
||||||
|
"postfix"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
timerConfig = {
|
postgresql = (defaultConfig "postgresql") // {
|
||||||
OnCalendar = "daily";
|
paths = [ "/tmp/postgresql-dump.sql.gz" ];
|
||||||
Persistent = true;
|
|
||||||
|
backupPrepareCommand = ''
|
||||||
|
${config.services.postgresql.package}/bin/pg_dumpall --clean \
|
||||||
|
| ${lib.getExe pkgs.gzip} --rsyncable \
|
||||||
|
> /tmp/postgresql-dump.sql.gz
|
||||||
|
'';
|
||||||
|
|
||||||
|
backupCleanupCommand = ''
|
||||||
|
rm /tmp/postgresql-dump.sql.gz
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue