minor improvements
This commit is contained in:
parent
2e243942da
commit
800206d4d9
@ -5,13 +5,19 @@
|
|||||||
####################################
|
####################################
|
||||||
PGDATA=/var/lib/pgsql/12/data
|
PGDATA=/var/lib/pgsql/12/data
|
||||||
PGDUMP="$(which pg_dump)"
|
PGDUMP="$(which pg_dump)"
|
||||||
|
PGDUMPALL="$(which pg_dumpall)"
|
||||||
PGDUMP="${PGDUMP} -h 127.0.0.1"
|
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)"
|
TODAY="$(date +%Y%m%d)"
|
||||||
NOW="$(date +%Y%m%d%H%M%S)"
|
NOW="$(date +%Y%m%d%H%M%S)"
|
||||||
|
|
||||||
# For debugging
|
####################################
|
||||||
WAITSEC=10
|
# output folders
|
||||||
|
####################################
|
||||||
|
|
||||||
BACKUPDIR="/var/lib/postgres/scripts/get_all_pgmetadata/${HOSTNAME,,}"
|
BACKUPDIR="/var/lib/postgres/scripts/get_all_pgmetadata/${HOSTNAME,,}"
|
||||||
LOGDIR="${BACKUPDIR}/logs/"
|
LOGDIR="${BACKUPDIR}/logs/"
|
||||||
@ -21,16 +27,35 @@ LOGDIR="${BACKUPDIR}/logs/"
|
|||||||
# multi-db support, this is auto
|
# multi-db support, this is auto
|
||||||
#DIFFILE="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
#DIFFILE="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
||||||
|
|
||||||
PSQL="$(which psql) -h 127.0.0.1"
|
|
||||||
|
|
||||||
CHANGEFILE=${BACKUPDIR}/$(basename $0 .sh)_changefile_${NOW}.log
|
|
||||||
DIFFILE=${BACKUPDIR}/$(basename $0 .sh)_changefile_${NOW}.log
|
|
||||||
|
|
||||||
LOGFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.log
|
LOGFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.log
|
||||||
SCRIPTLOG="${LOGFILE}"
|
SCRIPTLOG="${LOGFILE}"
|
||||||
ERRFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.err
|
ERRFILE=${LOGDIR}/$(basename $0 .sh)_${NOW}.err
|
||||||
SCRIPTLOGERR="${ERRFILE}"
|
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
|
# git usage
|
||||||
####################################
|
####################################
|
||||||
|
@ -11,12 +11,13 @@
|
|||||||
########################################################################
|
########################################################################
|
||||||
# INIT
|
# INIT
|
||||||
########################################################################
|
########################################################################
|
||||||
DEBUGME="${1:2}"
|
# moved to config
|
||||||
if [[ "${DEBUGME,,}" = "debug" ]] ; then
|
#DEBUGME="${1:2}"
|
||||||
DEBUG=0
|
#if [[ "${DEBUGME,,}" = "debug" ]] ; then
|
||||||
else
|
# DEBUG=0
|
||||||
DEBUG=1
|
#else
|
||||||
fi
|
# DEBUG=1
|
||||||
|
#fi
|
||||||
|
|
||||||
CONFIGFILE="$(dirname $(readlink -f $0))/$(basename $(readlink -f $0) .sh).config"
|
CONFIGFILE="$(dirname $(readlink -f $0))/$(basename $(readlink -f $0) .sh).config"
|
||||||
|
|
||||||
@ -157,6 +158,16 @@ generate_split_metadata()
|
|||||||
done 3< ${FULLMETADATA}
|
done 3< ${FULLMETADATA}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump_all_roles()
|
||||||
|
{
|
||||||
|
debug_me
|
||||||
|
if [[ ${DUMP_ROLE_PASSWORDS} -eq 0 ]] ; then
|
||||||
|
${PGDUMPALL} --roles-only > ${OUTPUTDIR}/dump_roles.sql
|
||||||
|
else
|
||||||
|
${PGDUMPALL} --roles-only --no-role-passwords > ${OUTPUTDIR}/dump_roles.sql
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
init_staff()
|
init_staff()
|
||||||
{
|
{
|
||||||
[[ ! -d ${BACKUPDIR} ]] && mkdir -p ${BACKUPDIR}
|
[[ ! -d ${BACKUPDIR} ]] && mkdir -p ${BACKUPDIR}
|
||||||
@ -218,11 +229,11 @@ if [[ "$(tty)" = "not a tty" ]] ; then
|
|||||||
exec 2> ${SCRIPTLOGERR}
|
exec 2> ${SCRIPTLOGERR}
|
||||||
elif [[ ${DEBUG} -eq 0 ]] ; then
|
elif [[ ${DEBUG} -eq 0 ]] ; then
|
||||||
echo -e "${BLUE}DEBUGMODE${RESET} is on"
|
echo -e "${BLUE}DEBUGMODE${RESET} is on"
|
||||||
echo -e "\t SCRIPTLOG will be ${SCRIPTLOG}"
|
#echo -e "\t SCRIPTLOG will be ${SCRIPTLOG}"
|
||||||
echo -e "\t SCRIPTLOGERR will be ${SCRIPTLOGERR}"
|
#echo -e "\t SCRIPTLOGERR will be ${SCRIPTLOGERR}"
|
||||||
set -x
|
#set -x
|
||||||
exec > ${SCRIPTLOG}
|
#exec > ${SCRIPTLOG}
|
||||||
exec 2> ${SCRIPTLOGERR}
|
#exec 2> ${SCRIPTLOGERR}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ ${DEBUG} -eq 0 ]] && DEBUGME="bash -x"
|
[[ ${DEBUG} -eq 0 ]] && DEBUGME="bash -x"
|
||||||
@ -235,13 +246,18 @@ debug_me
|
|||||||
for DBNAME in ${DATABASES} ; do
|
for DBNAME in ${DATABASES} ; do
|
||||||
FULLMETADATA="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
FULLMETADATA="${BACKUPDIR}/FULL_${DBNAME}_METADATA.sql"
|
||||||
|
|
||||||
|
debug_me "generate_full_metadata"
|
||||||
generate_full_metadata
|
generate_full_metadata
|
||||||
debug_me
|
if [[ ${SPLIPT_METADATA} -eq 0 ]] ; then
|
||||||
|
debug_me "generate_split_metadata"
|
||||||
generate_split_metadata
|
generate_split_metadata
|
||||||
debug_me
|
fi
|
||||||
|
debug_me "dump_all_roles"
|
||||||
|
dump_all_roles
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${ISGITREPO} -eq 0 ]] ; then
|
if [[ ${ISGITREPO} -eq 0 ]] ; then
|
||||||
|
debug_me "upload_to_git"
|
||||||
upload_to_git
|
upload_to_git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user