Recover a Persistent Database
A database container was removed, but its data volume survived. Prove you can back up, tear down, recreate, and restore a Postgres service without losing a row — the core disaster-recovery skill.
Learning objectives
- Identify the correct data volume
- Back up the database
- Recreate the service
- Restore the data
- Verify row counts match
Before you start
Required software: Docker Engine 24+
Prerequisites: Docker Storage path (or Fundamentals)
- Download and unzip the lab.
- Start it and seed data:
docker compose up -dthen run the providedseed.sh.
Instructions
Full instructions are part of Individual Pro
Unlock the step-by-step instructions, the solution guide, validation scripts, and downloadable files.
Hints
💡 Which volume holds the data?
docker volume ls then docker inspect the postgres container to see its mount — match the volume name to the mount target /var/lib/postgresql/data.
💡 Back up logically, not just the volume
A consistent logical backup (pg_dump) is safer than copying files from a live volume. Run pg_dump via docker exec and capture the output on the host.
Validate your work
From the lab folder, run:
bash validation/validate.sh The script reads only your local Docker state, never transmits data off your machine, and returns a status code:
0— Lab successfully completed1— Validation failed2— Required dependency missing3— Lab environment not running4— Configuration error5— Validation timed out
Note: validation targets Linux first. On Docker Desktop (macOS/Windows) some host-level checks (e.g. disk usage) may report differently; each script documents its limitations.
Solution
The full solution + troubleshooting explanation is available to Individual Pro members. Try to solve it first — that’s where the learning is.
Reset the lab
docker compose down -v && docker compose up -dfrom the original lab files restores the starting (broken) state.
Interview questions
- What’s the difference between backing up a volume’s files vs `pg_dump`?
- How do you find which volume a container uses?
- How would you verify a restore succeeded?
Finished this lab?
Sign in to record your completion and track progress across the path. Completion is recorded server-side.