This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Garcia
committed
Jun 11, 2020
1 parent
cd44004
commit 576681c
Showing
4 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#!/bin/bash | ||
# https://jeromejaglale.com/doc/programming/mongodb_docker_mongodump_mongorestore | ||
set -e | ||
|
||
echo "usage: ./backup_thethe_db.sh <mongo_user> <mongo_password>" | ||
echo "Doing database backup..." | ||
docker exec thethe_mongo sh -c 'mongodump --username root --password root --authenticationDatabase admin --archive' > db.dump | ||
gzip -c db.dump > db.dump.gz | ||
docker exec thethe_mongo sh -c "mongodump --username $1 --password $2 --authenticationDatabase admin --archive" >db.dump | ||
gzip -c db.dump >db.dump.gz | ||
rm db.dump |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#!/bin/bash | ||
# https://jeromejaglale.com/doc/programming/mongodb_docker_mongodump_mongorestore | ||
set -e | ||
|
||
echo "usage: ./restore_thethe_db.sh <mongo_user> <mongo_password>" | ||
echo "Restoring database from backup..." | ||
gzip -kd db.dump.gz | ||
docker exec -i thethe_mongo sh -c 'mongorestore --drop --username root --password root --authenticationDatabase admin --archive' < db.dump | ||
docker exec -i thethe_mongo sh -c "mongorestore --drop --username $1 --password $2 --authenticationDatabase admin --archive" <db.dump | ||
rm db.dump |