}
+#------------------------------------------------------------------------------
+backup_globals() {
+
+ empty_line
+ info "Backing up ${GREEN}globals${NORMAL} ..."
+
+ local output_sql="globals-${TIMESTAMP}.sql"
+ local output_sql_compressed="${output_sql}.bz2"
+ local out_sql_tmp="${TMP_DIR}/${output_sql}"
+ local out_sql_tmp_compressed="${TMP_DIR}/${output_sql_compressed}"
+ local out_sql_tgt="${BACKUP_DIR}/${output_sql}"
+ local out_sql_tgt_compressed="${BACKUP_DIR}/${output_sql_compressed}"
+
+ local verbose_option=""
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ verbose_option="--verbose"
+ fi
+
+ pg_dumpall --globals-only ${verbose_option} 2>&1 >"${out_sql_tmp}" | tee -a "${LOGFILE}"
+
+ local blocks=$(stat -c "%b" "${out_sql_tmp}")
+ local bs=$(stat -c "%B" "${out_sql_tmp}")
+ local bytes=$(stat -c "%s" "${out_sql_tmp}")
+ local b_bytes=$(( ${blocks} * ${bs} ))
+ local k_bytes=$(( ${b_bytes} / 1024 ))
+ local m_bytes=$(( ${k_bytes} / 1024 ))
+ local msg=$( printf "Original size of %-50s %10d Bytes => %7d KiB => %4d MiB" \
+ "'${output_sql}':" "${bytes}" "${k_bytes}" "${m_bytes}" )
+ info "${msg}"
+
+ debug "Compressing '${out_sql_tmp}' ..."
+ bzip2 ${verbose_option} --best "${out_sql_tmp}" 2>&1 | tee -a "${LOGFILE}"
+
+ blocks=$(stat -c "%b" "${out_sql_tmp_compressed}")
+ bs=$(stat -c "%B" "${out_sql_tmp_compressed}")
+ bytes=$(stat -c "%s" "${out_sql_tmp_compressed}")
+ b_bytes=$(( ${blocks} * ${bs} ))
+ k_bytes=$(( ${b_bytes} / 1024 ))
+ m_bytes=$(( ${k_bytes} / 1024 ))
+
+ BYTES_TOTAL=$(( ${BYTES_TOTAL} + ${b_bytes} ))
+
+ local msg=$( printf "Compressed size of %-50s %10d Bytes => %7d KiB => %4d MiB" \
+ "'${output_sql}':" "${bytes}" "${k_bytes}" "${m_bytes}" )
+ info "${msg}"
+
+ debug "Moving '${out_sql_tmp_compressed}' => '${BACKUP_DIR}' ..."
+ MV -i "${out_sql_tmp_compressed}" "${BACKUP_DIR}"
+
+}
+
#------------------------------------------------------------------------------
backup_databases() {
prepare_dirs
info "Starting backup ..."
get_databases
+ backup_globals
cleanup_old_backups
backup_databases