mirror of
https://github.com/RGBCube/ncc
synced 2025-07-31 12:07:48 +00:00
Back up postgresql
This commit is contained in:
parent
ccf0c5fee5
commit
2959c04419
1 changed files with 43 additions and 19 deletions
|
@ -1,14 +1,28 @@
|
||||||
{ 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
|
||||||
|
defaultConfig = name: {
|
||||||
|
repository = "sftp:backup@disk:${config.networking.hostName}-${name}";
|
||||||
passwordFile = config.secrets.resticPassword.path;
|
passwordFile = config.secrets.resticPassword.path;
|
||||||
initialize = true;
|
initialize = true;
|
||||||
|
|
||||||
repository = "sftp:backup@disk:${config.networking.hostName}-varlib";
|
pruneOpts = [
|
||||||
|
"--keep-daily 3"
|
||||||
|
"--keep-weekly 5"
|
||||||
|
"--keep-monthly 12"
|
||||||
|
"--keep-yearly 75"
|
||||||
|
];
|
||||||
|
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "daily";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
general = (defaultConfig "general") // {
|
||||||
paths = map (dir: "/var/lib/${dir}") [
|
paths = map (dir: "/var/lib/${dir}") [
|
||||||
"dkim"
|
"dkim"
|
||||||
"forgejo"
|
"forgejo"
|
||||||
|
@ -20,10 +34,20 @@ systemConfiguration {
|
||||||
"nextcloud"
|
"nextcloud"
|
||||||
"postfix"
|
"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