Skip to content

Commit cfb5b7c

Browse files
committed
Update database export/import documentation
1 parent 6283a4c commit cfb5b7c

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

docs/docs/threatstryker/selfmanaged/database-export-import.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,77 @@ Export Elasticsearch and PostgreSQL data from one management console and import
77
## Export
88

99
Connect to old management console / database, run following commands to export
10+
1011
```shell
1112
mkdir deepfence_export
1213
cd deepfence_export
1314

14-
docker run --net=host --rm=true --name=elasticsearch-export \
15+
docker run --net=host --rm=true --name=elasticsearch-backup \
1516
-v "$(pwd)":/data:rw \
1617
--entrypoint=/usr/local/bin/es-export.sh \
17-
-e ES_HOST="127.0.0.1" -e ES_PORT="9200" \
18+
-e EXPORT_ELASTICSEARCH_MAPPING="false" \
19+
-e ELASTICSEARCH_SCHEME="http" \
20+
-e ELASTICSEARCH_HOST="127.0.0.1" \
21+
-e ELASTICSEARCH_PORT="9200" \
22+
-e ELASTICSEARCH_USER="" \
23+
-e ELASTICSEARCH_PASSWORD="" \
1824
deepfenceio/deepfence_backup:latest
1925

20-
docker run --net=host --rm=true --name=postgresql-export \
26+
docker run --net=host --rm=true --name=postgresql-backup \
2127
-v "$(pwd)":/data:rw \
2228
--entrypoint=/usr/local/bin/pg-export.sh \
23-
-e POSTGRES_DB_HOST="127.0.0.1" -e POSTGRES_DB_PORT="5432" -e POSTGRES_DB_NAME=users -e POSTGRES_DB_USERNAME=deepfence -e POSTGRES_DB_PASSWORD=password \
29+
-e POSTGRES_DB_HOST="127.0.0.1" \
30+
-e POSTGRES_DB_PORT="5432" \
31+
-e POSTGRES_DB_NAME=users \
32+
-e POSTGRES_DB_USERNAME="" \
33+
-e POSTGRES_DB_PASSWORD="" \
2434
deepfenceio/deepfence_backup:latest
2535
```
2636

2737
## Migrate (Major version upgrade, for elasticsearch)
2838

2939
This step is required when the user is upgrading Deepfence Management Console to a major release. It can be skipped in other cases.
3040

41+
- Take a copy of backup files
42+
```shell
43+
cd ../
44+
cp -r deepfence_backup deepfence_backup_copy
45+
cd deepfence_backup
46+
```
47+
- Migrate elasticsearch data
48+
```shell
49+
docker run --net=host --rm=true --name=es-migrate \
50+
-v ${PWD}:/data:rw \
51+
--entrypoint=python3 \
52+
deepfenceio/deepfence_backup:latest \
53+
/usr/local/migrate_es.py
54+
```
55+
- `es_data.json.gz` is overwritten with new migrated data
56+
3157
## Import
58+
59+
Connect to new management console / database, run following commands to import
60+
61+
```shell
62+
docker run --net=host --rm=true --name=elasticsearch-restore \
63+
-v "$(pwd)":/data:rw \
64+
--entrypoint=/usr/local/bin/es-import.sh \
65+
-e IMPORT_ELASTICSEARCH_MAPPING="false" \
66+
-e ELASTICSEARCH_SCHEME="http" \
67+
-e ELASTICSEARCH_HOST="127.0.0.1" \
68+
-e ELASTICSEARCH_PORT="9200" \
69+
-e ELASTICSEARCH_USER="" \
70+
-e ELASTICSEARCH_PASSWORD="" \
71+
deepfenceio/deepfence_backup:latest
72+
73+
docker run --net=host --rm=true --name=postgresql-restore \
74+
-v "$(pwd)":/data:rw \
75+
--entrypoint=/usr/local/bin/pg-import.sh \
76+
-e POSTGRES_DB_HOST="127.0.0.1" \
77+
-e POSTGRES_DB_PORT="5432" \
78+
-e POSTGRES_DB_NAME=users \
79+
-e POSTGRES_DB_USERNAME="" \
80+
-e POSTGRES_DB_PASSWORD="" \
81+
deepfenceio/deepfence_backup:latest
82+
```
83+
- Restart management console once

0 commit comments

Comments
 (0)