library/roles/postgresql: Give the possibility to disable the postgresql backups. Create the list of dbs that need a backup automatically, if one is not provided.
This commit is contained in:
parent
a4025969f8
commit
8a23cbc153
|
@ -45,18 +45,20 @@ psql_db_user: db_user
|
||||||
psql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault"
|
psql_db_pwd: "We cannot save the password into the repository. Use another variable and change pgpass.j2 accordingly. Encrypt the file that contains the variable with ansible-vault"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postgres_install_gis_extensions: False
|
postgres_install_gis_extensions: False
|
||||||
postgres_gis_version: 2.1
|
postgres_gis_version: 2.1
|
||||||
postgres_gis_pkgs:
|
postgres_gis_pkgs:
|
||||||
- postgresql-'{{ psql_version }}'-postgis-'{{ postgres_gis_version }}'
|
- postgresql-'{{ psql_version }}'-postgis-'{{ postgres_gis_version }}'
|
||||||
|
|
||||||
|
|
||||||
|
pg_backup_enabled: True
|
||||||
pg_backup_logdir: /var/log/postgresql
|
pg_backup_logdir: /var/log/postgresql
|
||||||
pg_backup_bin: /usr/local/sbin/postgresql-backup
|
pg_backup_bin: /usr/local/sbin/postgresql-backup
|
||||||
pg_backup_pgdump_bin: /usr/bin/pg_dump
|
pg_backup_pgdump_bin: /usr/bin/pg_dump
|
||||||
pg_backup_retain_copies: 15
|
pg_backup_retain_copies: 15
|
||||||
pg_backup_build_db_list: "no"
|
pg_backup_build_db_list: "no"
|
||||||
pg_backup_db_list: '{{ psql_db_name}}'
|
# Dynamically created from psql_db_data if pg_backup_db_list is not set
|
||||||
|
#pg_backup_db_list: '{{ psql_db_name}}'
|
||||||
pg_backup_destdir: /var/lib/pgsql/backups
|
pg_backup_destdir: /var/lib/pgsql/backups
|
||||||
pg_backup_logdir: /var/log/postgresql
|
pg_backup_logdir: /var/log/postgresql
|
||||||
pg_backup_logfile: '{{ pg_backup_logdir }}/postgresql-backup.log'
|
pg_backup_logfile: '{{ pg_backup_logdir }}/postgresql-backup.log'
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
if [ -f /etc/default/pg_backup ] ; then
|
if [ -f /etc/default/pg_backup ] ; then
|
||||||
. /etc/default/pg_backup
|
. /etc/default/pg_backup
|
||||||
else
|
else
|
||||||
|
PG_BACKUP_ENABLED=True
|
||||||
PG_SERVICE=postgresql
|
PG_SERVICE=postgresql
|
||||||
USE_NAGIOS=no
|
USE_NAGIOS=no
|
||||||
LOG_DIR=/var/log/postgresql
|
LOG_DIR=/var/log/postgresql
|
||||||
|
@ -14,16 +15,20 @@ export PATH="/sbin:/usr/sbin:/usr/local/sbin:$PATH"
|
||||||
PG_SVC=$( service $PG_SERVICE status >/dev/null )
|
PG_SVC=$( service $PG_SERVICE status >/dev/null )
|
||||||
PG_RUNNING=$?
|
PG_RUNNING=$?
|
||||||
|
|
||||||
|
if [ '$PG_BACKUP_ENABLED' == 'True' ] ; then
|
||||||
|
if [ "$PG_RUNNING" -ne "0" -a "$PG_RUNNING" -ne "3" ] ; then
|
||||||
|
echo "The postgresql service is not running" > $LOG_FILE
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
if [ ! -d $LOG_DIR ] ; then
|
if [ ! -d $LOG_DIR ] ; then
|
||||||
mkdir -p $LOG_DIR
|
mkdir -p $LOG_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PG_RUNNING" -ne "0" -a "$PG_RUNNING" -ne "3" ] ; then
|
|
||||||
echo "postgresql not running" > $LOG_FILE
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
$PG_BCK_BIN > $LOG_FILE 2>&1
|
$PG_BCK_BIN > $LOG_FILE 2>&1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Postgresql backups administratively disabled" > $LOG_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${USE_NAGIOS}" == "yes" ] ; then
|
if [ "${USE_NAGIOS}" == "yes" ] ; then
|
||||||
N_LOGDIR=/var/log/nagios-checks
|
N_LOGDIR=/var/log/nagios-checks
|
||||||
if [ ! -d $N_LOGDIR ] ; then
|
if [ ! -d $N_LOGDIR ] ; then
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
PG_SERVICE=postgresql
|
PG_SERVICE=postgresql
|
||||||
|
PG_BACKUP_ENABLED={{ pg_backup_enabled }}
|
||||||
PG_VERSION={{ psql_version }}
|
PG_VERSION={{ psql_version }}
|
||||||
PG_DUMP_BIN={{ pg_backup_pgdump_bin }}
|
PG_DUMP_BIN={{ pg_backup_pgdump_bin }}
|
||||||
PG_BCK_BIN={{ pg_backup_bin }}
|
PG_BCK_BIN={{ pg_backup_bin }}
|
||||||
|
{% if pg_backup_enabled }}
|
||||||
USE_NAGIOS={{ pg_backup_use_nagios }}
|
USE_NAGIOS={{ pg_backup_use_nagios }}
|
||||||
|
{% else %}
|
||||||
|
USE_NAGIOS=no
|
||||||
|
{% endif %}
|
||||||
LOG_DIR={{ pg_backup_logdir }}
|
LOG_DIR={{ pg_backup_logdir }}
|
||||||
LOG_FILE={{ pg_backup_logfile}}
|
LOG_FILE={{ pg_backup_logfile}}
|
||||||
N_DAYS_TO_SPARE={{ pg_backup_retain_copies }}
|
N_DAYS_TO_SPARE={{ pg_backup_retain_copies }}
|
||||||
BUILD_DBLIST={{ pg_backup_build_db_list }}
|
BUILD_DBLIST={{ pg_backup_build_db_list }}
|
||||||
|
{% if pg_backup_db_list is defined %}
|
||||||
DB_LIST="{{ pg_backup_db_list }}"
|
DB_LIST="{{ pg_backup_db_list }}"
|
||||||
|
{% else %}
|
||||||
|
DB_LIST="{% for db in psql_db_data %}{{ db.name }} {% endfor %}"
|
||||||
|
{% endif %}
|
||||||
PG_USE_AUTH={{ pg_backup_use_auth }}
|
PG_USE_AUTH={{ pg_backup_use_auth }}
|
||||||
PG_PASS_FILE={{ pg_backup_pass_file }}
|
PG_PASS_FILE={{ pg_backup_pass_file }}
|
||||||
BACKUPDIR={{ pg_backup_destdir }}
|
BACKUPDIR={{ pg_backup_destdir }}
|
||||||
|
|
Loading…
Reference in New Issue