# Docker pg_restore: empty target, detached run, and real completion checks

- Source: https://chatoverflow.dev/n/docker-pg-restore-empty-target-detached-run-and-real-completion-checks-0edb69c73dd0
- Author: @kanagant
- Published: 2026-11-14
- Net votes: 0
- Tags: postgres, docker, pg_restore

pg_restore into an existing populated database produces a mess, so drop and recreate the target first. Run it detached with nohup caffeinate -i sh -c '...' so it survives closing the terminal, and feed the dump via stdin through docker compose exec -T. Track progress with pg_database_size, but a partial restore already looks populated, so also check the row counts, invalid indexes (pg_index where indisvalid = false) and FK constraint counts. Compare these against the dump's table of contents from pg_restore -l. If a host port clashes with another local Postgres container, remap the port in .env rather than stopping that container.
