From: Dimitri Bulgakov Date: Tue, 21 May 2019 13:13:06 +0000 (+0200) Subject: add option to set custom backupdir and make link to latest global instead of daily X-Git-Tag: 0.1.2~6^2~10^2^2~1 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=a78a96016f1a286265cfc60022222a3a3bbe001c;p=pixelpark%2Fadmin-tools.git add option to set custom backupdir and make link to latest global instead of daily --- diff --git a/bin/backup_pgsql.sh b/bin/backup_pgsql.sh index 0efbaea..1c778ce 100755 --- a/bin/backup_pgsql.sh +++ b/bin/backup_pgsql.sh @@ -17,7 +17,7 @@ ########################### # # * It stores all backup copies in directory '/var/vmail/backup' by default, -# You can change it in variable $BACKUP_ROOTDIR below. +# You can change it in variable $BACKUP_ROOTDIR below or via the -b parameter. # # * Set correct values for below variables: # @@ -145,12 +145,13 @@ description() { #------------------------------------------------------------------------------ usage() { cat <<-EOF - Usage: ${BASENAME} [-K DAYS|--keep=DAYS] [-d|--debug] [[-v|--verbose] | [-q|--quiet]]] [--nocolor] + Usage: ${BASENAME} [-K DAYS|--keep=DAYS] [-b DIR|--backupdir=DIR] [-d|--debug] [[-v|--verbose] | [-q|--quiet]]] [--nocolor] ${BASENAME} [-h|--help] ${BASENAME} [-V|--version] Options: -K|--keep DAYS Keep the backup files of the last DAYS. Default: ${KEEP_DAYS} days. + -b|--backupdir DIR Set backup directory. Sets backup rootdir to the same. Default today: ${BACKUP_DIR} -d|--debug Debug output (bash -x). -v|--verbose Set verbosity on. Mutually exclusive to '--quiet'. -q|--quiet Quiet execution, only errors and warnings are shown. @@ -190,6 +191,12 @@ get_options() { shift shift ;; + -b|--backupdir) + BACKUP_DIR="$2" + BACKUP_ROOTDIR="$2" + shift + shift + ;; -d|--debug) DEBUG="y" shift @@ -474,7 +481,7 @@ backup_globals() { 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 out_sql_tgt_latest="${BACKUP_DIR}/globals-latest.sql.bz2" + local out_sql_tgt_latest="${BACKUP_ROOTDIR}/globals-latest.sql.bz2" local verbose_option="" if [[ "${VERBOSE}" == "y" ]] ; then @@ -547,7 +554,7 @@ backup_database() { 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 out_sql_tgt_latest="${BACKUP_DIR}/${db}-latest.sql.bz2" + local out_sql_tgt_latest="${BACKUP_ROOTDIR}/${db}-latest.sql.bz2" local verbose_option="" if [[ "${VERBOSE}" == "y" ]] ; then