barman: Add wrapper script, minimum redundancy and backup max age

This commit is contained in:
Erwin Boskma 2024-10-10 08:41:09 +02:00
parent 6c88b600eb
commit 72c1018be1
Signed by: erwin
SSH key fingerprint: SHA256:/Wk1WZdLg+vQHs3in9qq7PsIp8SMzwGSk/RLZ5zPuZk
2 changed files with 29 additions and 11 deletions

View file

@ -23,6 +23,9 @@
streaming_archiver = true; streaming_archiver = true;
backup_method = "postgres"; backup_method = "postgres";
slot_name = "barman"; slot_name = "barman";
bandwidth_limit = 0;
last_backup_maximum_age = "3 DAYS";
minimum_redundancy = 3;
retention_policy = "RECOVERY WINDOW OF 4 WEEKS"; retention_policy = "RECOVERY WINDOW OF 4 WEEKS";
}; };
}; };

View file

@ -9,6 +9,27 @@ let
iniFormat = pkgs.formats.ini { }; iniFormat = pkgs.formats.ini { };
defaultUser = "barman"; defaultUser = "barman";
defaultHome = "/var/lib/barman"; defaultHome = "/var/lib/barman";
runtimeInputs = with pkgs; [
cfg.package
bash
bzip2
gzip
lz4
pigz
postgresql
zstd
];
barmanWrapper = pkgs.writeShellApplication {
name = "bm";
inherit runtimeInputs;
text = ''
sudo --set-home --user ${cfg.settings.barman.barman_user} -- ${cfg.package}/bin/barman "$@"
'';
};
in in
{ {
options.services.barman = { options.services.barman = {
@ -73,7 +94,10 @@ in
}; };
}) cfg.servers); }) cfg.servers);
systemPackages = [ cfg.package ]; systemPackages = [
cfg.package
barmanWrapper
];
}; };
systemd = { systemd = {
timers.barman = { timers.barman = {
@ -87,16 +111,7 @@ in
services.barman = { services.barman = {
description = "Run barman maintenance tasks"; description = "Run barman maintenance tasks";
path = with pkgs; [ path = runtimeInputs;
cfg.package
bash
bzip2
gzip
lz4
pigz
postgresql
zstd
];
# environment = { # environment = {
# PGPASSFILE = lib.mkIf (cfg.passwordsFile != null) cfg.passwordsFile; # PGPASSFILE = lib.mkIf (cfg.passwordsFile != null) cfg.passwordsFile;
# }; # };