mirror of
https://github.com/RGBCube/ncc
synced 2025-07-29 19:17:45 +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 {
|
||||
secrets.resticPassword.file = ./password.age;
|
||||
|
||||
services.restic.backups.general = {
|
||||
passwordFile = config.secrets.resticPassword.path;
|
||||
initialize = true;
|
||||
services.restic.backups = let
|
||||
defaultConfig = name: {
|
||||
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}") [
|
||||
"dkim"
|
||||
"forgejo"
|
||||
"gitea-runner"
|
||||
"grafana"
|
||||
"mail"
|
||||
"matrix-sliding-sync"
|
||||
"matrix-synapse"
|
||||
"nextcloud"
|
||||
"postfix"
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
general = (defaultConfig "general") // {
|
||||
paths = map (dir: "/var/lib/${dir}") [
|
||||
"dkim"
|
||||
"forgejo"
|
||||
"gitea-runner"
|
||||
"grafana"
|
||||
"mail"
|
||||
"matrix-sliding-sync"
|
||||
"matrix-synapse"
|
||||
"nextcloud"
|
||||
"postfix"
|
||||
];
|
||||
};
|
||||
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
postgresql = (defaultConfig "postgresql") // {
|
||||
paths = [ "/tmp/postgresql-dump.sql.gz" ];
|
||||
|
||||
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