From 459853e353297576feda853e7f2f6f04f4d2197d Mon Sep 17 00:00:00 2001 From: Dimitri Bulgakov Date: Tue, 21 May 2019 14:33:04 +0200 Subject: [PATCH] adding reference to latest backup for easy retrieval --- bin/backup_pgsql.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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}" } -- 2.39.5