This repository was archived by the owner on Jun 27, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,9 +16,27 @@ All parameters must be supplied as environment variables:
1616| MONGODB\PASSWORD | yes |
1717| MONGODB\_ DATABASE | yes |
1818| OUTPUT | |
19+ | GPG\_ PASSWORD | |
20+
21+ If you set ` GPG_PASSWORD ` , the resulting archive will be encrypted (symmetrically, with the given passphrase).
22+ This is recommended if you dump the database on your personal laptop because of data security.
1923
2024After exporting these environment variables to your bash, run:
21- ```
25+
26+ ``` bash
2227./remote-dump.sh
2328```
2429
30+
31+ # Import into your local mongo db (optional)
32+
33+ Run (but change the file name accordingly):
34+ ``` bash
35+ mongorestore --gzip --archive=human-connection-dump_2018-11-21.archive
36+ ```
37+
38+ If you previously encrypted your dump, run:
39+ ``` bash
40+ gpg --decrypt human-connection-dump_2018-11-21.archive.gpg | mongorestore --gzip --archive
41+ ```
42+
Original file line number Diff line number Diff line change @@ -16,9 +16,17 @@ echo "MONGODB_USERNAME ${MONGODB_USERNAME}"
1616echo " MONGODB_PASSWORD ${MONGODB_PASSWORD} "
1717echo " MONGODB_DATABASE ${MONGODB_DATABASE} "
1818echo " OUTPUT_FILE_NAME ${OUTPUT_FILE_NAME} "
19+ echo " GPG_PASSWORD ${GPG_PASSWORD:- <none>} "
1920echo " -------------------------------------------------"
2021
2122ssh -M -S my-ctrl-socket -fnNT -L 27018:localhost:27017 -l ${SSH_USERNAME} ${SSH_HOST}
22- mongodump --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase admin --gzip --archive=${OUTPUT_FILE_NAME}
23+
24+ if [[ -z " ${! GPG_PASSWORD} " ]]; then
25+ mongodump --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase admin --gzip --archive | gpg -c --batch --passphrase ${GPG_PASSWORD} --output ${OUTPUT_FILE_NAME} .gpg
26+ else
27+ mongodump --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase admin --gzip --archive=${OUTPUT_FILE_NAME}
28+ fi
29+
30+
2331ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}
2432ssh -S my-ctrl-socket -O exit -l ${SSH_USERNAME} ${SSH_HOST}
You can’t perform that action at this time.
0 commit comments