131
131
fi
132
132
133
133
if [ -z "${DB_HOST}" ] && [ -n "${parsed_host}" ]; then
134
- print_debug "Parsed DBHostpho Variant: 3 - No Env, Parsed Filename"
134
+ print_debug "Parsed DBHost Variant: 3 - No Env, Parsed Filename"
135
135
q_dbhost_variant=3
136
136
q_dbhost_menu=$(cat <<EOF
137
137
335
335
case "${q_dbtype_variant}" in
336
336
1 )
337
337
while true; do
338
- read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}M${cdgy}\) | \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
338
+ read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \ | \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
339
339
case "${q_dbtype,,}" in
340
340
m* )
341
341
r_dbtype=mysql
358
358
;;
359
359
2 )
360
360
while true; do
361
- read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
361
+ read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh} P${cdgy}\) : ${cwh}${coff}) " q_dbtype
362
362
case "${q_dbtype,,}" in
363
363
e* | "" )
364
364
r_dbtype=${DB_TYPE}
385
385
;;
386
386
3 )
387
387
while true; do
388
- read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
388
+ read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh} P${cdgy}\) : ${cwh}${coff}) " q_dbtype
389
389
case "${q_dbtype,,}" in
390
390
f* | "" )
391
391
r_dbtype=${p_dbtype}
413
413
414
414
4 )
415
415
while true; do
416
- read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
416
+ read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh} P${cdgy}\) : ${cwh}${coff}) " q_dbtype
417
417
case "${q_dbtype,,}" in
418
418
e* | "" )
419
419
r_dbtype=${DB_TYPE}
427
427
r_dbtype=mysql
428
428
break
429
429
;;
430
+ o* )
431
+ r_dbtype=mongo
432
+ break
433
+ ;;
430
434
p* )
431
435
r_dbtype=postgresql
432
436
break
@@ -915,6 +919,30 @@ case "${r_dbtype}" in
915
919
exit_code=$?
916
920
;;
917
921
mongo )
922
+ cat << EOF
923
+
924
+ Do you wish to drop any existing data before restoring?
925
+ Y ) Yes
926
+ N ) No
927
+ Q ) Quit
928
+
929
+ EOF
930
+
931
+ echo -e "${coff}"
932
+ read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}Y${cdgy}\) \| \(${cwh}N${cdgy}\) \| \(${cwh}Q${cdgy}\) : ${cwh}${coff})" q_menu_mongo_dropdb
933
+ case "${q_menu_mongo_dropdb,,}" in
934
+ "y" | "yes" | * )
935
+ mongo_dropdb="--drop"
936
+ ;;
937
+ "n" | "update" )
938
+ unset mongo_dropdb
939
+ ;;
940
+ "q" | "exit" )
941
+ print_info "Quitting Script"
942
+ exit 1
943
+ ;;
944
+ esac
945
+
918
946
print_info "Restoring '${r_filename}' into '${r_dbhost}'/'${r_dbname}'"
919
947
if [ "${ENABLE_COMPRESSION,,}" != "none" ] && [ "${ENABLE_COMPRESSION,,}" != "false" ] ; then
920
948
mongo_compression="--gzip"
@@ -928,7 +956,8 @@ case "${r_dbtype}" in
928
956
if [ -n "${DB_AUTH}" ] ; then
929
957
mongo_auth_database="--authenticationDatabase=${DB_AUTH}"
930
958
fi
931
- mongorestore ${mongo_compression} -d=${r_dbname} -h=${r_dbhost} --port=${r_dbport} ${mongo_user} ${mongo_pass} --archive=${r_filename} ${mongo_auth_database}
959
+
960
+ mongorestore ${mongo_compression} -d=${r_dbname} -h=${r_dbhost} --port=${r_dbport} ${mongo_dropdb} ${mongo_user} ${mongo_pass} --archive=${r_filename} ${mongo_auth_database}
932
961
exit_code=$?
933
962
;;
934
963
* )
@@ -942,4 +971,4 @@ if [ "${exit_code}" = 0 ] ; then
942
971
print_info "Restore complete!"
943
972
else
944
973
print_error "Restore reported errors"
945
- fi
974
+ fi
0 commit comments