cmd+=" --verbose"
fi
cmd+=" --log-error=\"${errorlog}\""
- cmd+=" | gzip -9 > \"${dumpfile}\""
+ cmd+=" | gzip -9"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd+=" --verbose"
+ fi
+ cmd+=" > \"${dumpfile}\""
if [[ "${SIMULATE}" == "y" ]] ; then
info "Executing: ${cmd}"
return
}
+#------------------------------------------------------------------------------
+do_postgres_backup() {
+
+ empty_line
+ info "Dumping PostgreSQL Databases ..."
+
+ debug "Dumping PostgreSQL globals ..."
+ local dumpfile="${BACKUP_DIR}/postgres.@globals.dump.sql.gz"
+ local cmd="su - postgres -c \"pg_dumpall"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd+=" --verbose"
+ fi
+ cmd+=" --globals-only --clean --encoding=utf-8 --disable-triggers --if-exists\""
+ cmd+=" | gzip -9"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd+=" --verbose"
+ fi
+ cmd+=" > \"${dumpfile}\""
+ if [[ "${SIMULATE}" == "y" ]] ; then
+ info "Executing: ${cmd}"
+ else
+ debug "Executing: ${cmd}"
+ eval ${cmd}
+ fi
+
+ local db=
+
+ for db in $( su - postgres -c "psql -X -x --list --tuples-only --no-align" | \
+ grep -i '^name|' | awk -F'|' '{print $2}' ) ; do
+ debug "Dumping PostgreSQL database '${CYAN}${db}${NORMAL}' ..."
+ dumpfile="${BACKUP_DIR}/postgres.${db}.dump.sql.gz"
+ cmd="su - postgres -c \"pg_dump"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd+=" --verbose"
+ fi
+ cmd+=" --blobs --clean --create --encoding=utf-8 --disable-triggers --if-exists '${db}'\""
+ cmd+=" | gzip -9"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd+=" --verbose"
+ fi
+ cmd+=" > \"${dumpfile}\""
+ if [[ "${SIMULATE}" == "y" ]] ; then
+ info "Executing: ${cmd}"
+ continue
+ fi
+ debug "Executing: ${cmd}"
+ eval ${cmd}
+ done
+
+}
+
#------------------------------------------------------------------------------
create_checksums() {
if [[ "${DO_MYSQL}" == "y" ]] ; then
do_mysql_backup
fi
+ if [[ "${DO_POSTGRES}" == "y" ]] ; then
+ do_postgres_backup
+ fi
create_checksums
clean_old_backups
sync_to_remote