Commit 8c4fa93f authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

db dump is for deploy, as we use need it will be run as soon as possible

parent 527901fe
......@@ -6,4 +6,35 @@ docker run -v $(pwd)/persistent_volume:/code/persistent_volume -e "USE_SQLITE_AS
```
docker run --name db-test_db -e POSTGRES_PASSWORD=eee -e POSTGRES_DB=viralhostrangedb -e POSTGRES_USER=postgres -e LC_COLLATE=POSIX -p 5432:5432 -d postgres:10.1
```
\ No newline at end of file
```
## How to load a specific dump in PostgreSQL
Useful when upgrading PostgreSQL, or restoring the DB after cluster migration.
### get a dump
Get it from the CI as it is an artifact
### clean up
```
export CI_COMMIT_REF_SLUG="split-deploy"
# Stop web to prevent manage.py migrate
kubectl delete deployments -l branch=branch-$CI_COMMIT_REF_SLUG
# Stop the db, and delete its storage
kubectl delete statefulsets,pvc -l app.kubernetes.io/instance=db-$CI_COMMIT_REF_SLUG
```
Do keep the storage of the web container
# load the data from the dump
```
dev_db=$(kubectl --namespace=$NAMESPACE get po -l branch=branch-${CI_COMMIT_REF_SLUG},app=postgres-app --output jsonpath='{.items[0].metadata.name}' || echo "")
echo $dev_db
export POSTGRES_PASSWORD=toto
kubectl --namespace=$NAMESPACE exec -i $dev_db -- bash -c "PGPASSWORD=$POSTGRES_PASSWORD psql -U postgres viralhostrangedb" < prod.sql
```
# Restart
Re-run CI job deploy_web_*
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment