131131 fi
132132
133133 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"
135135 q_dbhost_variant=3
136136 q_dbhost_menu=$(cat <<EOF
137137
335335 case "${q_dbtype_variant}" in
336336 1 )
337337 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
339339 case "${q_dbtype,,}" in
340340 m* )
341341 r_dbtype=mysql
358358 ;;
359359 2 )
360360 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
362362 case "${q_dbtype,,}" in
363363 e* | "" )
364364 r_dbtype=${DB_TYPE}
385385 ;;
386386 3 )
387387 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
389389 case "${q_dbtype,,}" in
390390 f* | "" )
391391 r_dbtype=${p_dbtype}
413413
414414 4 )
415415 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
417417 case "${q_dbtype,,}" in
418418 e* | "" )
419419 r_dbtype=${DB_TYPE}
427427 r_dbtype=mysql
428428 break
429429 ;;
430+ o* )
431+ r_dbtype=mongo
432+ break
433+ ;;
430434 p* )
431435 r_dbtype=postgresql
432436 break
@@ -915,6 +919,30 @@ case "${r_dbtype}" in
915919 exit_code=$?
916920 ;;
917921 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+
918946 print_info "Restoring '${r_filename}' into '${r_dbhost}'/'${r_dbname}'"
919947 if [ "${ENABLE_COMPRESSION,,}" != "none" ] && [ "${ENABLE_COMPRESSION,,}" != "false" ] ; then
920948 mongo_compression="--gzip"
@@ -928,7 +956,8 @@ case "${r_dbtype}" in
928956 if [ -n "${DB_AUTH}" ] ; then
929957 mongo_auth_database="--authenticationDatabase=${DB_AUTH}"
930958 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}
932961 exit_code=$?
933962 ;;
934963 * )
@@ -942,4 +971,4 @@ if [ "${exit_code}" = 0 ] ; then
942971 print_info "Restore complete!"
943972else
944973 print_error "Restore reported errors"
945- fi
974+ fi
0 commit comments