Skip to content

99 ‐ Backups

LRVT edited this page Jul 30, 2024 · 15 revisions

General Backup Strategy

The ./volume-data/database Docker bind mount volume holds all application data.

Within this bind mount directory, you will typically find:

  • The db.sqlite3 file if sqlite3 is used as database engine (default)
  • The psql directory, which holds your PostgreSQL database data if postgres is used as database engine
  • The uploads directory, which holds a subdirectory per user with user-specific file uploads (PDFs and images)

Therefore, by backing up this bind mount volume, all application data is saved.

Warning

Read the official SQLite3 documentation or PostgreSQL documentation regarding backups.

Manual Backups via Django

You can also dump the database content manually using Django's manage.py.

This may help if something bricks and you have to re-import your application data into a freshly spawned VoucherVault container.

Proceed as follows:

Export data

# exec into the vouchervault container
docker exec -it vouchervault bash

# export sqlite3 database tables into outfile
python manage.py dumpdata auth.group > database/backup_db_table_groups.json
python manage.py dumpdata auth.user > database/backup_db_table_users.json
python manage.py dumpdata myapp.item > database/backup_db_table_items.json
python manage.py dumpdata myapp.transaction > database/backup_db_table_transactions.json

You will find the backup files within the Docker bind mount volume dir ./volume-data/database/.

Import data

# import old backup outfiles into sqlite3
python manage.py loaddata database/backup_db_table_groups.json
python manage.py loaddata database/backup_db_table_users.json
python manage.py loaddata database/backup_db_table_items.json
python manage.py loaddata database/backup_db_table_transactions.json