]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
adding reference to latest backup for easy retrieval
authorDimitri Bulgakov <dimitri.bulgakov@pixelpark.com>
Tue, 21 May 2019 12:33:04 +0000 (14:33 +0200)
committerDimitri Bulgakov <dimitri.bulgakov@pixelpark.com>
Tue, 21 May 2019 12:33:04 +0000 (14:33 +0200)
bin/backup_pgsql.sh

index 844ca655c31ac38b755154d8c2387914f78fc93a..a0db4ae619789d88db218f6796b959e790a25cf1 100755 (executable)
@@ -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}"
 }