mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 13:23:12 +01:00
Merge pull request #107 from piemonkey/mongo-restore
Add Mongo support to restore script
This commit is contained in:
@@ -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
|
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
|
case "${q_dbtype,,}" in
|
||||||
e* | "" )
|
e* | "" )
|
||||||
r_dbtype=${db_name}
|
r_dbtype=${DB_TYPE}
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
m* )
|
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
|
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
|
case "${q_dbtype,,}" in
|
||||||
e* | "" )
|
e* | "" )
|
||||||
r_dbtype=${dbtype}
|
r_dbtype=${DB_TYPE}
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
f* )
|
f* )
|
||||||
@@ -826,7 +826,7 @@ if [ -n "${3}" ]; then
|
|||||||
if [ ! -f "${3}" ]; then
|
if [ ! -f "${3}" ]; then
|
||||||
get_dbhost
|
get_dbhost
|
||||||
else
|
else
|
||||||
r_dbtype="${3}"
|
r_dbhost="${3}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
get_dbhost
|
get_dbhost
|
||||||
@@ -920,8 +920,23 @@ case "${r_dbtype}" in
|
|||||||
pv ${r_filename} | ${decompress_cmd}cat | psql -d ${r_dbname} -h ${r_dbhost} -p ${r_dbport} -U ${r_dbuser}
|
pv ${r_filename} | ${decompress_cmd}cat | psql -d ${r_dbname} -h ${r_dbhost} -p ${r_dbport} -U ${r_dbuser}
|
||||||
exit_code=$?
|
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
|
print_info "Unable to restore DB of type '${r_dbtype}'"
|
||||||
|
exit_code=3
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user