db_backup/restore_mongo.sh
2023-06-15 11:00:55 +07:00

19 lines
397 B
Bash

#!/bin/bash
echo "[Restore mongo] start"
if [ "$#" -ne 1 ]
then
echo "You must pass the path of the backup file to restore"
fi
echo "=> Restore database from $1"
set -o pipefail
RESTORE_CMD="mongorestore --host ${MONGODB_HOST} --port ${MONGODB_PORT} -d ${MONGO_DB} $1"
if ${RESTORE_CMD}
then
echo "=> Restore succeeded"
else
echo "=> Restore failed"
fi
echo "[Restore mongo] finish"