Skip to content
Snippets Groups Projects
Commit 229d9565 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

skip couchdb backup if seq id is ureadable

parent c4cc527e
No related branches found
No related tags found
1 merge request!106skip couchdb backup if seq id is ureadable
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
# LOCALDUMP :: COUCHDB2 - using nodejs tools couchbackup and couchrestore # LOCALDUMP :: COUCHDB2 - using nodejs tools couchbackup and couchrestore
# https://github.com/cloudant/couchbackup # https://github.com/cloudant/couchbackup
# #
# creates gzipped plain text backups (JSON) from each scheme # Backup:
# - creates gzipped plain text backups (JSON) from each scheme
# - write sequence id into a text file
# - store extra file with security infos
# - latest backup set is written to archive
# #
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# ah - Axel Hahn <axel.hahn@iml.unibe.ch> # ah - Axel Hahn <axel.hahn@iml.unibe.ch>
...@@ -22,6 +26,7 @@ ...@@ -22,6 +26,7 @@
# 2022-04-21 v1.7 restore security infos # 2022-04-21 v1.7 restore security infos
# 2022-10-07 ah v1.8 unescape regex with space to prevent "grep: warning: stray \ before white space" # 2022-10-07 ah v1.8 unescape regex with space to prevent "grep: warning: stray \ before white space"
# 2023-06-06 ah v1.9 show a warning if the sequence id was not fetched # 2023-06-06 ah v1.9 show a warning if the sequence id was not fetched
# 2023-06-12 ah v1.10 skip couchdb dump if no sequence id was detected (=db deleted since fetching list of all dbs)
# ================================================================================ # ================================================================================
if [ -z "$BACKUP_TARGETDIR" ]; then if [ -z "$BACKUP_TARGETDIR" ]; then
...@@ -223,31 +228,31 @@ function _doBackupOfSingleInstance(){ ...@@ -223,31 +228,31 @@ function _doBackupOfSingleInstance(){
echo "WARNING: unable to fetch current sequence ID - maybe the database was deleted." echo "WARNING: unable to fetch current sequence ID - maybe the database was deleted."
else else
echo echo
fi echo "update_seq --+-- current [${sSequenceCurrent}]"
echo "update_seq --+-- current [${sSequenceCurrent}]" echo " +-- backup [${sSequenceLast}]"
echo " +-- backup [${sSequenceLast}]" echo -n "Need to backup ... "
echo -n "Need to backup ... " couchbackup --db "${dbname}" >"${OUTFILE}".progress 2>/dev/null && mv "${OUTFILE}".progress "${OUTFILE}"
couchbackup --db "${dbname}" >"${OUTFILE}".progress 2>/dev/null && mv "${OUTFILE}".progress "${OUTFILE}"
fetchrc
# $myrc is last returncode - set in fetchrc
if [ $myrc -eq 0 ]; then
echo -n "gzip ... "
compress_file "$OUTFILE"
fetchrc fetchrc
# $myrc is last returncode - set in fetchrc
if [ $myrc -eq 0 ]; then if [ $myrc -eq 0 ]; then
iDbCount+=1 echo -n "gzip ... "
cp "${OUTFILE}"* "${ARCHIVFILE}" \ compress_file "$OUTFILE"
&& echo "${sSequenceCurrent}">"${SEQFILE}" \ fetchrc
&& _couchapi GET "${dbname}/_security" > "${SECURITYFILE}" if [ $myrc -eq 0 ]; then
ls -l "${ARCHIVFILE}" "${SEQFILE}" "${SECURITYFILE}" iDbCount+=1
cp "${OUTFILE}"* "${ARCHIVFILE}" \
&& echo "${sSequenceCurrent}">"${SEQFILE}" \
&& _couchapi GET "${dbname}/_security" > "${SECURITYFILE}"
ls -l "${ARCHIVFILE}" "${SEQFILE}" "${SECURITYFILE}"
fi
else
echo "ERROR occured while dumping - abort"
fi fi
else ls -l "$OUTFILE"*
echo "ERROR occured while dumping - abort" echo
fi fi # if [ -z "$sSequenceCurrent" ]; then
ls -l "$OUTFILE"* fi # if [ "${sSequenceCurrent}" = "${sSequenceLast}" ] ...
echo
fi
done done
rm -f "$dblist" rm -f "$dblist"
echo "__DB__$SERVICENAME backup INFO: ${COUCHDB_INSTANCE} - backed up $iDbCount dbs of $iDbTotal total" echo "__DB__$SERVICENAME backup INFO: ${COUCHDB_INSTANCE} - backed up $iDbCount dbs of $iDbTotal total"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment