This repository was archived by the owner on Jun 27, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,27 @@ All parameters must be supplied as environment variables:
16
16
| MONGODB\PASSWORD | yes |
17
17
| MONGODB\_ DATABASE | yes |
18
18
| 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.
19
23
20
24
After exporting these environment variables to your bash, run:
21
- ```
25
+
26
+ ``` bash
22
27
./remote-dump.sh
23
28
```
24
29
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}"
16
16
echo " MONGODB_PASSWORD ${MONGODB_PASSWORD} "
17
17
echo " MONGODB_DATABASE ${MONGODB_DATABASE} "
18
18
echo " OUTPUT_FILE_NAME ${OUTPUT_FILE_NAME} "
19
+ echo " GPG_PASSWORD ${GPG_PASSWORD:- <none>} "
19
20
echo " -------------------------------------------------"
20
21
21
22
ssh -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
+
23
31
ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}
24
32
ssh -S my-ctrl-socket -O exit -l ${SSH_USERNAME} ${SSH_HOST}
You can’t perform that action at this time.
0 commit comments