Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Modified db utils scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
David Garcia committed Jun 11, 2020
1 parent cd44004 commit 576681c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ Inside **utils** folder:
Make a backup

```bash
backup_thethe_db.sh
backup_thethe_db.sh <mongo_user> <mongo_password>
```

Restore from a backup

```bash
restore_thethe_db.sh
restore_thethe_db.sh <mongo_user> <mongo_password>
```

backup filename is **db.dump.gz**
Expand Down
2 changes: 1 addition & 1 deletion thethe_frontend
Submodule thethe_frontend updated 1 files
+1 −1 package.json
6 changes: 4 additions & 2 deletions utils/backup_thethe_db.sh
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
4 changes: 3 additions & 1 deletion utils/restore_thethe_db.sh
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

0 comments on commit 576681c

Please sign in to comment.