Back-up and restore
Why do you need this?
There are several reasons when you need to use back-up and restore.
- You need to migrate your DB from the container to the stand-alone version (which is a must for production with big amount of tests).
- You care about your data and do not want to lose the data.
Backups and restoration of data from backups
How to make the backup of the database for docker-compose deployment
Before you start the backup process or restore process, please stop all the containers which do not have -db_
in their names.
Allure TestOps databases backup
docker exec -t [CONTAINER_WITH_DB] pg_dump -c -U [POSTGRESQL_USER] > [prefix-]backup.sql
where
CONTAINER_WITH_DB is the name of a container running the database.
POSTGRESQL_USER is the Postgres DB user name, you will find it in
.env
file
[prefix-] is the prefix for the file with DB dump, it is worth go name the files something like **uaa-**backup.sql and so on.
Restore a database
If you are started the containers using docker-compose, you need to stop the containers without the databases as described in the prerequisites section.
Drop the existing (presumably empty) database
docker exec -it [POSTGRESQL_CONTAINER] psql -U [POSTGRESQL_USER] -d postgres -c "DROP DATABASE [POSTGRESQL_DATABASE]"
- POSTGRESQL_DATABASE is either report or uaa
Create empty database
docker exec -it [POSTGRESQL_CONTAINER] psql -U [POSTGRESQL_USER] -d postgres -c "CREATE DATABASE [POSTGRESQL_DATABASE]"
- POSTGRESQL_DATABASE is either report or uaa
Restore from previously made backup
cat backup.sql | docker exec -i [POSTGRESQL_CONTAINER] psql -U [POSTGRESQL_USER] -d [POSTGRESQL_DATABASE]
- POSTGRESQL_DATABASE is either report or uaa
How to make the backup of the database for Kubernetes deployment
Allure TestOps databases backup
- Stop all Allure TestOPs pods except the DB ones.
- Create the DB dump as follows:
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
where
- pod-name is the name of the Postgres pod.
- postgres-user is the database user that is able to access the database.
- database-name is the name of the database.
Allure TestOps databases restoration
cat database.sql | kubectl exec -i [pod-name] -- psql -U [postgres-user] -d [database-name]
© Qameta Software Inc. All rights reserved.