Created
August 9, 2016 14:29
-
-
Save ivanhuay/59c5a63d3eb81cb45e2d131774088770 to your computer and use it in GitHub Desktop.
Simple scripr for restore mongo volumen from .tar file
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_CONTAINER=$1 | |
INPUT_FILE=$2 | |
if [ $# -eq 2 ];then | |
if echo $INPUT_FILE |grep '.tar' ;then | |
docker run --rm --volumes-from $DOCKER_MONGO_CONTAINER -v $(pwd):/backup ubuntu bash -c "cd /data && tar xvf /backup/$INPUT_FILE --strip 1" | |
if [ $? -eq 0 ]; then | |
echo "volume success loaded to $DOCKER_MONGO_CONTAINER"; | |
echo "Restarting container." | |
docker restart $DOCKER_MONGO_CONTAINER; | |
else | |
echo "Error loading volume." | |
fi | |
else | |
echo "Invalid out_file: \"$INPUT_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