Skip to content

Instantly share code, notes, and snippets.

@cristianounix
Created June 4, 2018 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianounix/23d0f2fd04938159423643f92afb5289 to your computer and use it in GitHub Desktop.
Save cristianounix/23d0f2fd04938159423643f92afb5289 to your computer and use it in GitHub Desktop.
Restore mongo database in your container (named mongo)
#!/bin/bash
if [ -s "$1" ]
then
MONGO_STATUS=$(docker inspect -f {{.State.Running}} mongo)
if [ "$MONGO_STATUS" != "true" ]
then
echo "Mongo is not running"
exit 1
fi
else
echo "Syntax: $0 <filename>"
exit 1
fi
cat $1 | docker exec -i mongo mongorestore --drop --gzip --archive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment