Skip to content

Commit

Permalink
mongo backup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dimafeng committed Jun 1, 2015
1 parent a306d10 commit 7ac7f9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/mongo-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -rf /tmp/mongodump && mkdir /tmp/mongodump
docker run -it --rm --link mongo:mongo -v /tmp/mongodump:/tmp mongo bash -c 'mongodump -v --host $MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT --db '$1' --out=/tmp'
tar -cvf $2 -C /tmp/mongodump *
rm -rf /tmp/mongodump
15 changes: 15 additions & 0 deletions scripts/mongo-restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rm -rf $TMP_DIR && mkdir $TMP_DIR
if [[ $1 =~ \.tar$ ]];
then
#FILENAME=$(echo $1 | sed 's/.*\///')
FILENAME=$2"/"
mkdir $TMP_DIR
echo "Data will be extracted into :"$TMP_DIR
tar -C $TMP_DIR -xvf $1
else
FILENAME=$(echo $1 | sed 's/.*\///')
cp $1 $TMP_DIR$FILENAME
fi

docker run -it --rm --link mongo:mongo -v $TMP_DIR:/tmp mongo bash -c 'mongorestore --drop -v --host $MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT --db '$2' /tmp/'$FILENAME
rm -rf $TMP_DIR

0 comments on commit 7ac7f9a

Please sign in to comment.