Skip to content

Commit 2cfd40e

Browse files
committed
Add script for doing the rocket chat db dump and minor fix
1 parent 778b41e commit 2cfd40e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ user.csv
33
mysql.sql
44
kratos.sql
55
temp.sql
6-
dump-*.zip
6+
dump-*
77

88
# Local enmeshed connector
99
/enmeshed/logs

deploy/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Set up the Gsutil. You need to authenticate and may use a key of the appropriate
5050
### DB Migration Cronjob
5151

5252
Add a crontab in host with the following command (replace the missing values) for 3 am.
53+
5354
```
5455
docker run --rm --name db-migration --env-file PATH/TO/.env -e SLACK_CHANNEL="PLACEHOLDER" -e SLACK_TOKEN="PLACEHOLDER" --network staging-network ghcr.io/serlo/api.serlo.org/db-migration:PLACEHOLDER
5556
```
@@ -64,15 +65,25 @@ Set up the Gsutil. You need the credentials of a service account in order that t
6465

6566
1. Go to GC Console -> IAM -> Service Accounts -> choose the dbreader account -> generate a new one
6667
2. Put the key in a file `production_service_account_key.json` in the home directory
67-
3. Set cron tab to run the dbsetup script every night at 1 am.
68+
3. Set cron tab to run the dbdump script every night at 1 am.
6869

6970
### Rocket Chat DB Dump
7071

71-
You need to set up a cronjob for doing the db dump of rocket chat every night
72+
In your first deployment, you will need to import the existing data into mongodb container.
73+
74+
1. Download the dump from the corresponding bucket in the GC project 'production'
75+
2. Run
76+
```
77+
$ docker compose cp dump-????.gz mongodb:/dump.gz
78+
$ docker compose exec mongodb mongorestore --archive=dump.gz --gzip
79+
```
80+
81+
Now, set up a crontab to upload a backup of the data to the bucket at midnight, using the script `mongodbdump.sh`.
7282

7383
### DB Migration
7484

7585
In case of db migration, run the following command in host (replace the missing values).
86+
7687
```
7788
docker run --rm --name db-migration --env-file PATH/TO/.env -e SLACK_CHANNEL="PLACEHOLDER" -e SLACK_TOKEN="PLACEHOLDER" --network production-network ghcr.io/serlo/api.serlo.org/db-migration:PLACEHOLDER
78-
```
89+
```

0 commit comments

Comments
 (0)