-
Notifications
You must be signed in to change notification settings - Fork 22
99 ‐ Backups
The ./volume-data/database Docker bind mount volume holds all application data.
Within this bind mount directory, you will typically find:
- The
db.sqlite3file ifsqlite3is used as database engine (default) - The
psqldirectory, which holds your PostgreSQL database data ifpostgresis used as database engine - The
uploadsdirectory, 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.
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. Alternatively, if you switch database types and want to move your data to a new instance.
Proceed as follows:
# exec into the vouchervault container
docker exec -it vouchervault bash
# export 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/.
# spawn a new vouchervault instance
# copy export files to the bind mount volume
# exec into a new vouchervault container
docker exec -it vouchervault-new bash
# import old backup outfiles into new database
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
Afterwards you can authenticate with your previous user accounts at the new VoucherVault instance. All previous application data will be available again.
Warning
Ensure to transfer the ./database/uploads/ bind mount volume from the old instance to the new instance too. A simple copy operation does the job. This folder contains all user file uploads.