Postgres backup fixes

This commit is contained in:
Dave Conroy
2019-03-09 07:29:51 -08:00
parent bf672c0fda
commit 9051ba559a
2 changed files with 7 additions and 2 deletions

View File

@@ -1,3 +1,8 @@
## 1.13 - 2019-03-09 - <dave at tiredofit dot ca>
* Fixed Postgres backup without SPLIT_DB enabled (credit MelwinKfr@github)
* Added DB_PORT reference to properly backup Postgres with non default ports (thanks Maxximus007@github)
## 1.12 - 2019-03-01 - <stevetodorov at github> ## 1.12 - 2019-03-01 - <stevetodorov at github>
* Fix for XZ Compression failing * Fix for XZ Compression failing

View File

@@ -146,7 +146,7 @@ function backup_mongo() {
function backup_pgsql() { function backup_pgsql() {
if [ "$SPLIT_DB" = "TRUE" ] || [ "$SPLIT_DB" = "true" ]; then if [ "$SPLIT_DB" = "TRUE" ] || [ "$SPLIT_DB" = "true" ]; then
export PGPASSWORD=${DBPASS} export PGPASSWORD=${DBPASS}
DATABASES=`psql -h $DBHOST -U $DBUSER -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;' ` DATABASES=`psql -h $DBHOST -U $DBUSER -p ${DBPORT} -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;' `
for db in $DATABASES; do for db in $DATABASES; do
echo "** [db-backup] Dumping database: $db" echo "** [db-backup] Dumping database: $db"
TARGET=pgsql_${db}_${DBHOST}_${now}.sql TARGET=pgsql_${db}_${DBHOST}_${now}.sql
@@ -157,7 +157,7 @@ function backup_pgsql() {
done done
else else
export PGPASSWORD=${DBPASS} export PGPASSWORD=${DBPASS}
pg_dump -h ${DBHOST} -U ${DBUSER} $db > ${TMPDIR}/${TARGET} pg_dump -h ${DBHOST} -U ${DBUSER} -p ${DBPORT} ${DBNAME} > ${TMPDIR}/${TARGET}
generate_md5 generate_md5
compression compression
move_backup move_backup