Skip to content

Instantly share code, notes, and snippets.

@ivanhuay
Created August 9, 2016 14:10
Show Gist options
  • Save ivanhuay/b759cd0211d5b593058f7c52694ab08b to your computer and use it in GitHub Desktop.
Save ivanhuay/b759cd0211d5b593058f7c52694ab08b to your computer and use it in GitHub Desktop.
Simple script for backup the volume if mongodb container
#!/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