2022-07-26 14:48:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# cron vars
|
|
|
|
####################################
|
|
|
|
PGDATA=/var/lib/pgsql/12/data
|
|
|
|
PGDUMP="$(which pg_dump)"
|
2022-07-26 14:59:28 +00:00
|
|
|
PGDUMPALL="$(which pg_dumpall)"
|
2022-07-26 14:48:29 +00:00
|
|
|
PGDUMP="${PGDUMP} -h 127.0.0.1"
|
2022-07-26 14:59:28 +00:00
|
|
|
PGDUMPALL="${PGDUMPALL} -h 127.0.0.1"
|
|
|
|
|
|
|
|
PSQL="$(which psql) -h 127.0.0.1"
|
|
|
|
|
2022-07-26 14:48:29 +00:00
|
|
|
|
|
|
|
TODAY="$(date +%Y%m%d)"
|
|
|
|
NOW="$(date +%Y%m%d%H%M%S)"
|
|
|
|
|
2022-07-26 14:59:28 +00:00
|
|
|
####################################
|
|
|
|
# output folders
|
|
|
|
####################################
|
2022-07-26 14:48:29 +00:00
|
|
|
|
|
|
|
BACKUPDIR="/var/lib/postgres/scripts/get_all_pgmetadata/${HOSTNAME,,}"
|
|
|
|
LOGDIR="${BACKUPDIR}/logs/"
|
|
|
|
|
|
|
|
# multi-db support, this is auto
|
|
|
|
#FULLMETADATA="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
|
|
|
# multi-db support, this is auto
|
|
|
|
#DIFFILE="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
|
|
|
|
|
|
|
LOGFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.log
|
|
|
|
SCRIPTLOG="${LOGFILE}"
|
|
|
|
ERRFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.err
|
|
|
|
SCRIPTLOGERR="${ERRFILE}"
|
|
|
|
|
2022-07-26 14:59:28 +00:00
|
|
|
####################################
|
|
|
|
# output options
|
|
|
|
####################################
|
|
|
|
|
|
|
|
# set to 0 to split full metadata into files (DEFAULT behavior)
|
|
|
|
SPLIT_METADATA=0
|
|
|
|
|
|
|
|
# dump user passwords
|
|
|
|
DUMP_ROLE_PASSWORDS=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# DEBUG
|
|
|
|
####################################
|
|
|
|
|
|
|
|
# set to 0 to debug
|
|
|
|
DEBUG=0
|
|
|
|
DEBUG=1
|
|
|
|
|
|
|
|
|
|
|
|
# For debugging
|
|
|
|
WAITSEC=10
|
|
|
|
|
2022-07-26 14:48:29 +00:00
|
|
|
####################################
|
|
|
|
# git usage
|
|
|
|
####################################
|
|
|
|
# for git usage you'll have to create a git repo on the git server
|
|
|
|
# then import it into the ${BACKUPDIR} so authentication & config is done
|
|
|
|
# then this script will make `git push` automatically if ISGITREPO=0
|
|
|
|
|
|
|
|
# set to 0 if git is in place
|
|
|
|
ISGITREPO=0
|
|
|
|
ISGITREPO=1
|
|
|
|
|
|
|
|
|