Skip to content
Snippets Groups Projects

couchdb2 v1.2 added fastmode in restore

Merged Hahn Axel (hahn) requested to merge version-2 into master
1 file
+ 24
17
Compare changes
  • Side-by-side
  • Inline
@@ -13,6 +13,8 @@
@@ -13,6 +13,8 @@
# 2019-11-13 ..... v1.0 initial version with backup and restore (single DB)
# 2019-11-13 ..... v1.0 initial version with backup and restore (single DB)
# 2020-05-19 ..... v1.1 backup a single or multiple couchdb instances by globbing param
# 2020-05-19 ..... v1.1 backup a single or multiple couchdb instances by globbing param
# ./localdump.sh backup couchdb2 demo
# ./localdump.sh backup couchdb2 demo
 
# 2021-10-11 ..... v1.2 added fastmode in restore: no test connect, do not
 
# delete DB before create request
# ================================================================================
# ================================================================================
if [ -z $BACKUP_TARGETDIR ]; then
if [ -z $BACKUP_TARGETDIR ]; then
@@ -203,6 +205,8 @@ function _doBackupOfSingleInstance(){
@@ -203,6 +205,8 @@ function _doBackupOfSingleInstance(){
function restoreByFile(){
function restoreByFile(){
sMyfile=$1
sMyfile=$1
sMyDb=$2
sMyDb=$2
 
bFastMode=1
 
echo
echo
h2 "analyze dump $sMyfile"
h2 "analyze dump $sMyfile"
@@ -218,20 +222,21 @@ function restoreByFile(){
@@ -218,20 +222,21 @@ function restoreByFile(){
echo
echo
loadInstance $COUCHDB_INSTANCE
loadInstance $COUCHDB_INSTANCE
echo connect $couchdbhost on port $couchdbport with user $couchdbuser
if [ $bFastMode -eq 0 ]; then
curl --head -X GET $COUCH_URL 2>/dev/null | grep "^HTTP.*\ 200\ " >/dev/null
echo connect $couchdbhost on port $couchdbport with user $couchdbuser
if [ $? -ne 0 ]; then
curl --head -X GET $COUCH_URL 2>/dev/null | grep "^HTTP.*\ 200\ " >/dev/null
color error
if [ $? -ne 0 ]; then
echo ERROR: couch DB instance is not available
color error
curl -X GET $COUCH_URL
echo ERROR: couch DB instance is not available
 
curl -X GET $COUCH_URL
 
color reset
 
exit 1
 
fi
 
color ok
 
echo OK
color reset
color reset
exit 1
fi
fi
color ok
echo OK
color reset
echo
echo
@@ -240,11 +245,13 @@ function restoreByFile(){
@@ -240,11 +245,13 @@ function restoreByFile(){
# echo DB exists ... need to drop it first
# echo DB exists ... need to drop it first
# fi
# fi
h2 deleting database [$sMyDb] ...
if [ $bFastMode -eq 0 ]; then
color cmd
h2 deleting database [$sMyDb] ...
_couchapi DELETE $sMyDb
color cmd
fetchrc
_couchapi DELETE $sMyDb
color reset
fetchrc
 
color reset
 
fi
h2 creating database [$sMyDb] ...
h2 creating database [$sMyDb] ...
color cmd
color cmd
Loading