Created
August 9, 2016 14:10
-
-
Save ivanhuay/b759cd0211d5b593058f7c52694ab08b to your computer and use it in GitHub Desktop.
Simple script for backup the volume if mongodb container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOCKER_MONGO_IMAGE=$1 | |
OUT_FILE=$2 | |
if [ $# -eq 2 ];then | |
if echo $OUT_FILE |grep '.tar' ;then | |
docker run --rm --volumes-from $DOCKER_MONGO_IMAGE -v $(pwd):/backup ubuntu tar cvf /backup/$OUT_FILE /data/db | |
else | |
echo "Invalid out_file: \"$OUT_FILE\". The out file require .tar extension!" | |
fi | |
else | |
echo "docker_image and out_file.tar is required" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment