Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
intermediate Premium Storage & Volumes · ⏱ 40 min

Recover a Persistent Database

Scenario

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)

  1. Download and unzip the lab.
  2. Start it and seed data: docker compose up -d then run the provided seed.sh.

Instructions

Full instructions are part of Individual Pro

Unlock the step-by-step instructions, the solution guide, validation scripts, and downloadable files.

Unlock with Pro

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 completed
  • 1 — Validation failed
  • 2 — Required dependency missing
  • 3 — Lab environment not running
  • 4 — Configuration error
  • 5 — 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.

Upgrade to Pro

Reset the lab

  • docker compose down -v && docker compose up -d from 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.

Related labs