opensafely-core / opencodelists

OpenCodelists is an open platform for creating and sharing codelists of clinical terms and drugs.
https://www.opencodelists.org
Other
31 stars 11 forks source link

Use sqlite cli to backup core database #2151

Open lucyb opened 6 days ago

lucyb commented 6 days ago

We recently noticed a problem with restoring the existing backup of the core database (#2091).

Rather than try to fix it, this is a proposal to replace the current backup with a sqlite .dump instead.

We should also strongly consider making the backups into a different directory to the production sqlite database, for ease of management and to reduce potential for any errors.

See slack 🧵.

This blog post evaluates the options available for backing up a SQLite db.

Assumptions

We'll be using the official sqlite cli, so it's less likely to have problems than using manage.py dumpdata / loaddata. It's also likely to use less memory than the current mange.py loaddata command, which may be significant on our relatively small server.

The current approach doesn't backup some sensitive tables (namely the django session tables), to support its use in local development. I don't believe that will be an issue, as we are planning to move away from using production data (unless for a specified purpose) in local development and because in practice people aren't using this data anyway.

Acceptance criteria

Note: There will be a separate issue for the coding systems databases.

This ticket will fix #2091.