From e0dd2bc91b4c94405a43db2aac56562018b51500 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 22 Mar 2022 09:07:20 +0100 Subject: [PATCH 1/4] Set db type from env vars correctly during restore --- install/usr/local/bin/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/usr/local/bin/restore b/install/usr/local/bin/restore index 48dde2d..c24cc49 100755 --- a/install/usr/local/bin/restore +++ b/install/usr/local/bin/restore @@ -351,7 +351,7 @@ EOF read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype case "${q_dbtype,,}" in e* | "" ) - r_dbtype=${db_name} + r_dbtype=${DB_TYPE} break ;; m* ) @@ -398,7 +398,7 @@ EOF read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype case "${q_dbtype,,}" in e* | "" ) - r_dbtype=${dbtype} + r_dbtype=${DB_TYPE} break ;; f* ) From 06677dbc8b4901c4208e097fad55980771c86623 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 22 Mar 2022 09:08:47 +0100 Subject: [PATCH 2/4] Fix typo setting dbhost in restore script --- install/usr/local/bin/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/usr/local/bin/restore b/install/usr/local/bin/restore index c24cc49..b2c8731 100755 --- a/install/usr/local/bin/restore +++ b/install/usr/local/bin/restore @@ -826,7 +826,7 @@ if [ -n "${3}" ]; then if [ ! -f "${3}" ]; then get_dbhost else - r_dbtype="${3}" + r_dbhost="${3}" fi else get_dbhost From 52dc510b89c94d4e8bdde3f8b2d8814b795b8077 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 22 Mar 2022 09:10:10 +0100 Subject: [PATCH 3/4] Add auto restore support for mongodb --- install/usr/local/bin/restore | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install/usr/local/bin/restore b/install/usr/local/bin/restore index b2c8731..cb88a14 100755 --- a/install/usr/local/bin/restore +++ b/install/usr/local/bin/restore @@ -920,6 +920,20 @@ case "${r_dbtype}" in pv ${r_filename} | ${decompress_cmd}cat | psql -d ${r_dbname} -h ${r_dbhost} -p ${r_dbport} -U ${r_dbuser} exit_code=$? ;; + mongo ) + print_info "Restoring '${r_filename}' into '${r_dbhost}'/'${r_dbname}'" + if [ "${ENABLE_COMPRESSION,,}" != "none" ] && [ "${ENABLE_COMPRESSION,,}" != "false" ] ; then + mongo_compression="--gzip" + fi + if [ -n "${r_dbuser}" ] ; then + mongo_user="-u ${r_dbuser}" + fi + if [ -n "${r_dbpass}" ] ; then + mongo_pass="-u ${r_dbpass}" + fi + mongorestore ${mongo_compression} -d ${r_dbname} -h ${r_dbhost} --port ${r_dbport} ${mongo_user} ${mongo_pass} --archive=${r_filename} + exit_code=$? + ;; * ) exit 3 ;; From e7eb88c32ac1c8905f6f7350f209c0495c5d06d8 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 22 Mar 2022 09:12:34 +0100 Subject: [PATCH 4/4] Give feedback if restore script doesn't support db type --- install/usr/local/bin/restore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/usr/local/bin/restore b/install/usr/local/bin/restore index cb88a14..dbee688 100755 --- a/install/usr/local/bin/restore +++ b/install/usr/local/bin/restore @@ -935,7 +935,8 @@ case "${r_dbtype}" in exit_code=$? ;; * ) - exit 3 + print_info "Unable to restore DB of type '${r_dbtype}'" + exit_code=3 ;; esac