Consistent database backups in containers
Database consistency means the recovered data obeys the database’s rules at a defined recovery point. A volume stores files, but it does not coordinate transactions. An archive of changing database files may mix different moments in time. Database-supported backup mechanisms are designed to handle this problem.
Worked storage scenario
Use the synthetic scenario offline first. No real data, daemon changes, host mounts or production resources are required. Commands, if shown, are documented examples rather than observed output. Any real Docker check requires an approved disposable context. Keep the exercise offline. For any separately authorized Docker verification, identify the effective endpoint (including DOCKER_HOST and DOCKER_CONTEXT) before sending even read-only Engine requests. Record server version and platform; redact sensitive metadata.
Fictional transfer: total balance must remain 100Before commit: account A=60, B=40After commit: account A=50, B=50Mixed-time file copy: A=60, B=50 (illustrative, not a real database format)Recovery targets: total=100; expected records; app read testThe mixed copy violates the example invariant even though each number looked valid separately. For PostgreSQL, a logical dump using supported tools can capture a database-consistent view; it has different restore and scope properties from physical backups. A filesystem-level copy requires the database to be shut down or a documented consistent snapshot/backup procedure, including relevant files and logs. A point-in-time recovery design also needs the required base backup and archived WAL (write-ahead log) records. Review engine version, roles and global objects, extensions, recovery target, encryption and retention. Verify restoration in an isolated compatible database and run checks for key records and application behavior. A volume snapshot without database coordination is not automatically application-consistent. The transfer numbers are a conceptual model only. A single logical database dump does not by itself include all cluster-global roles or establish point-in-time recovery. Choose the recovery approach before the backup, record its scope and test the required restore point. For the fictional transfer, totals are 100, 100 and 110 respectively.
Common mistake
Stopping one application container is not sufficient if another writer or the database itself is still changing files. Use a documented database-specific approach.
Manual practice
Calculate the totals before, after and in the mixed copy. Choose a database-aware backup approach and define two restore acceptance checks. No database server is required for this worksheet.
Worksheet: lab-fixtures/docker-storage-engineering/04-database-consistency/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Consistent database backups in containers — Knowledge check
Reason about storage behavior and recovery evidence.
Which pair violates the transfer invariant?
What is required for a plain PostgreSQL filesystem backup?
Which is a useful recovery acceptance check?