-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
760 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Backup and Restore database | ||
|
||
Commands used relate to full docker based deployment | ||
|
||
## Backup | ||
|
||
### `db_export.py` script | ||
|
||
The `db_export.py` file defines a full model backup for all database tables for the version it has been specified for and should be used for periodic backups. | ||
|
||
At times the data model may change in anticipation of a new release. When this happens the updated `db_export.py` file should be pushed to the running container prior to backup. | ||
|
||
``` | ||
docker cp server/swagger_server/backup/utils/db_export.py api-flask-server:/code/server/swagger_server/backup/utils/db_export.py | ||
``` | ||
|
||
### run script from the container | ||
|
||
Exec onto the running container | ||
|
||
``` | ||
docker exec -ti api-flask-server /bin/bash | ||
``` | ||
|
||
Run the backup script which saves database tables as json file | ||
|
||
``` | ||
source .env | ||
source .venv/bin/activate | ||
python -m server.swagger_server.backup.utils.db_export | ||
exit | ||
``` | ||
|
||
Copy the backup files to the local filesystem | ||
|
||
``` | ||
docker cp api-flask-server:/code/server/swagger_server/backup/data . | ||
``` | ||
|
||
A copy of the `data` directory will now be locally available. | ||
|
||
## Restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.