diff --git a/ReadMe.md b/ReadMe.md index d57e37b..fd941ee 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -21,11 +21,13 @@ Two files must be created Example file is `pgbackrest.sample.cfg` -This file holds the sudo_user for calling the commands +This file holds the sudo_user for calling the commands and the main pgbackrest config file. +If the super user or config file does not exists an error will be shown ```ini [PgBackRest] sudo_user=postgres +pgbackrest_config=/etc/pgbackrest.conf ``` ### `config/stanza.cfg` @@ -44,7 +46,14 @@ The forth optional parameter is the super user to use If parameters are not used but laters are, the empties need to be set with just the ":" -`stanza::/conifg` +`stanza::/config` + +The script checks for the following things during each run + +- stanza name exists in the main config file, or in the override config file if set +- check if repo number exist in main config file, or in the override config file if set +- override config file exists +- override super does not exist ```ini [stanzas] diff --git a/bin/pgbackrest_backup.sh b/bin/pgbackrest_backup.sh index 2216c7c..251a384 100755 --- a/bin/pgbackrest_backup.sh +++ b/bin/pgbackrest_backup.sh @@ -71,6 +71,10 @@ if [ -z "${sudo_user}" ]; then echo "sudo_user not set in the config file ${config_file}"; exit; fi; +if ! id "${sudo_user}" &>/dev/null; then + echo "Sudo user ${sudo_user} does not exist, skipping stanza"; + exit +fi; if [ -z "${pgbackrest_config}" ] ||[ ! -f "${pgbackrest_config}" ]; then echo "Missing pgbackrest default config file ${pgbackrest_config}"; exit; @@ -218,6 +222,10 @@ while read -r stanza; do fi; # set override sudo user if [ -n "${stanza_super_user}" ]; then + if ! id "${stanza_super_user}" &>/dev/null; then + echo "[!] Sudo user ${stanza_super_user} for stanza ${stanza_name} does not exist, skipping stanza"; + continue; + fi; sudo_user="${stanza_super_user}"; fi; # build the call command