71 lines
1.6 KiB
Bash
71 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
####################################
|
|
# cron vars
|
|
####################################
|
|
PGDATA=/var/lib/pgsql/12/data
|
|
PGDUMP="$(which pg_dump)"
|
|
PGDUMPALL="$(which pg_dumpall)"
|
|
PGDUMP="${PGDUMP} -h 127.0.0.1"
|
|
PGDUMPALL="${PGDUMPALL} -h 127.0.0.1"
|
|
|
|
PSQL="$(which psql) -h 127.0.0.1"
|
|
|
|
|
|
TODAY="$(date +%Y%m%d)"
|
|
NOW="$(date +%Y%m%d%H%M%S)"
|
|
|
|
####################################
|
|
# output folders
|
|
####################################
|
|
|
|
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}"
|
|
|
|
####################################
|
|
# 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
|
|
|
|
####################################
|
|
# 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
|
|
|
|
|