diff --git a/README.md b/README.md index 7f19a9f..0f1b50c 100644 --- a/README.md +++ b/README.md @@ -206,13 +206,13 @@ Debian/Ubuntu ###### PostgreSQL versions: all supported PostgreSQL versions -:white_check_mark: tested, works fine: `PostgreSQL 9.4, 10` +:white_check_mark: tested, works fine: `PostgreSQL 9.4, 10, 11` ## Requirements pgbackrest >= 2.01 -for `--checkdb`: -- [amcheck_next](https://github.com/petergeoghegan/amcheck) extension/SQL version >=2. +for `--checkdb`: +- [amcheck_next](https://github.com/petergeoghegan/amcheck) extension/SQL version >=2 `(if PostgreSQL version <= 10)`. >You can use the packages for your PostgreSQL version from the [APT](https://apt.postgresql.org/pub/repos/apt/pool/main/a/amcheck/) repository diff --git a/pgbackrest_auto b/pgbackrest_auto index 7462013..a7d5ca1 100644 --- a/pgbackrest_auto +++ b/pgbackrest_auto @@ -8,7 +8,7 @@ # Requirements: local trust for postgres (login by Unix domain socket) in the pg_hba.conf or ".pgpass" # Run as user: postgres -ver="1.0" +ver="1.1" # variables for function "sendmail()" smtp_server="10.128.64.5:25" @@ -450,8 +450,11 @@ function pg_data_validation(){ } # amcheck - verify the logical consistency of the structure of PostgreSQL B-Tree indexes function pg_logical_validation(){ - for db in "${ok_dbArray[@]}"; do - if pg_isready 1> /dev/null; then + for db in "${ok_dbArray[@]}"; do + if pg_isready 1> /dev/null; then + if [[ "$PGVER" -ge "11" && "$PGVER" -lt "90" ]]; then + ${bin_dir}/psql -p "${port}" -U postgres -d "$db" -tAc "CREATE EXTENSION if not exists amcheck" 1> /dev/null + else ${bin_dir}/psql -p "${port}" -U postgres -d "$db" -tAc "CREATE EXTENSION if not exists amcheck_next" 1> /dev/null if [[ $? -eq 0 ]]; then info "Verify the logical consistency of the structure of indexes and heap relations in the database \e[1m$db\e[0m" @@ -459,13 +462,14 @@ function pg_logical_validation(){ for index in $indexes; do # info "\e[90mVerify the logical consistency of the structure of index\e[0m ${index}" ${bin_dir}/psql -p "${port}" -d "$db" -tAc "SELECT bt_index_parent_check('${index}', true)" 1> /dev/null - if [[ $? -ne 0 ]]; then - errmsg "Logical validation for index \e[1m${index}\e[0m ( database \e[1m$db\e[0m ) - \e[91mFailed\e[0m" - fi + if [[ $? -ne 0 ]]; then + errmsg "Logical validation for index \e[1m${index}\e[0m ( database \e[1m$db\e[0m ) - \e[91mFailed\e[0m" + fi done fi fi - done + fi + done } # Send report to mail address