# The database restore with no rows

A PostgreSQL archive restored successfully into a scratch database, but the
orders table has no rows. Investigate what the archive contains, then create
and test a complete logical backup without changing the original database.

## Before you begin

Use Docker with Compose, Python 3 and Bash on a disposable machine. The first
run may download the PostgreSQL 17 image. The lab uses synthetic data, an
internal Docker network and a named lab volume; it publishes no host ports.
Authentication is deliberately insecure. Never use these settings or project
name for real workloads. Other containers or users with Docker daemon access
may access the lab database.

The project name `breakfix-dbops-02` is reserved for this lab. Setup refuses to
reuse existing project resources. Teardown verifies container ownership before
removing the project's containers, network and database volume.

## Investigate

Run `./setup.sh`, then open a shell in the database container:

```sh
docker compose -p breakfix-dbops-02 exec db sh
```

The source database is `lab`, the scratch database is `recovery`, and the
initial archive is `/tmp/partial.dump`. Connect with `psql -U lab_admin`.
Compare the `orders` table in both databases and inspect the archive with
`pg_restore -l /tmp/partial.dump`.

Create a complete PostgreSQL custom-format archive at `/tmp/full.dump`. Restore
it into the separate `recovery` database, not over `lab`. Preserve the source
and its data. Exit the container shell, run `./verify.sh`, then run
`./teardown.sh`. Verification also restores the new archive into its own
temporary database and checks its contents; teardown deletes the lab data.

The [related restore guide and demo](https://opsbreakfix.com/devops/test-a-backup-restore-before-you-need-it/#see-it-run)
discuss checking restored data. Its video demonstrates a file restore, not this
PostgreSQL exercise; the guide notes that its database commands were not run.
