From: Dimitri Bulgakov Date: Tue, 21 May 2019 12:33:04 +0000 (+0200) Subject: adding reference to latest backup for easy retrieval X-Git-Tag: 0.1.2~6^2~10^2^2~4 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=459853e353297576feda853e7f2f6f04f4d2197d;p=pixelpark%2Fadmin-tools.git adding reference to latest backup for easy retrieval --- diff --git a/bin/backup_pgsql.sh b/bin/backup_pgsql.sh index 844ca65..a0db4ae 100755 --- a/bin/backup_pgsql.sh +++ b/bin/backup_pgsql.sh @@ -338,6 +338,15 @@ RMDIR() { eval ${cmd} "$@" 2>&1 | tee -a "${LOGFILE}" } +#------------------------------------------------------------------------------ +LN() { + local cmd="ln" + if [[ "${VERBOSE}" == "y" ]] ; then + cmd+=" --verbose" + fi + eval ${cmd} "$@" 2>&1 | tee -a "${LOGFILE}" +} + #------------------------------------------------------------------------------ empty_line() { if [[ "${QUIET}" == "y" ]] ; then @@ -534,6 +543,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 verbose_option="" if [[ "${VERBOSE}" == "y" ]] ; then @@ -573,6 +583,8 @@ backup_database() { debug "Moving '${out_sql_tmp_compressed}' => '${BACKUP_DIR}' ..." MV -i "${out_sql_tmp_compressed}" "${BACKUP_DIR}" + debug "Updating reference '${out_sql_tgt_latest}' -> '${out_sql_tgt_compressed}'" + LN -sf "${out_sql_tgt_compressed}" "${out_sql_tgt_latest}" }