Goal: restore a physical cluster copy separately and prove what it captured.
A physical backup copies the cluster’s files plus required WAL, like copying a workshop and its repair journal. Inspect actual wal_level/max_wal_senders first; do not assume their starting values. Set replica/10 with ALTER SYSTEM and restart. These settings permit physical WAL-sender connections; the superuser is used only for this admin lab. Verify the active settings after restart.
All hints here run at the Linux shell. psql -c runs quoted SQL and exits, with -v ON_ERROR_STOP=1 stopping on SQL errors. -h /tmp in the backup command selects the Unix socket directory, not a remote hostname.
Goal: see why tar format must be unpacked before running.
-Ft writes archive files, including base.tar and pg_wal.tar; -Xs streams WAL while copying and -c fast requests an immediate checkpoint. List the files, then remove only this throwaway tar directory so there is room for the plain copy. The final backup is taken next; no retained recovery archive is being deleted.
The skipped-special-file warnings refer to log symlinks, not database table files. -Xs uses a second WAL-sender connection to stream the recovery journal while the main connection copies the files. TAR_BACKUP_READY prints only if the backup command succeeds; && skips that message after a failure.
Goal: record a known row in the backup before changing the source.
Create a separate backup_probe table with the marker before-backup. Take a plain (-Fp) backup owned by the student; -D names its new destination, -Xs includes WAL, -P prints progress, and -c fast requests a checkpoint. That can impose load in production. Expect 100% progress and a manifest/control file.
Goal: check file/WAL integrity before attempting startup.
Inspect the major version and top-level files: expect PG_VERSION 19, base/global, backup_label, backup_manifest, and pg_wal. pg_verifybackup compares the manifest and parses required WAL. Its success is stronger than listing filenames, but a real startup and data check are still needed; no utility proves every possible recovery condition.
Goal: prove the restored server uses the captured files independently.
Change the primary marker to after-backup, then start the backup directory as a student-owned server on port 5434 and socket /tmp. -o passes server settings; -l chooses its startup log; -w waits. The source stays on 5432. Using an explicit port/directory avoids accidentally querying the source.
Goal: verify recovery completed and the connection is to the copy.
Query port, data directory, and pg_is_in_recovery on 5434. Expect 5434, /tmp/basebackup, false. No standby.signal was requested (-R was not used), so after required WAL replay this is an independent primary. False alone is not a data-completeness check.
Goal: prove the copy retained the earlier marker and is writable.
Read the original marker on 5432 (after-backup), then the restored marker on 5434 (before-backup) and the copied beer count (400). Update the copy inside BEGIN and ROLLBACK; RETURNING must show writable-check, then the marker returns to before-backup. This proves a captured version and independent writable instance, not equality to a primary that has since changed.
Goal: leave the source running after a verified physical restore.
Fast shutdown rolls back active transactions and waits for a clean stop. Expect server stopped and COPY_CLUSTER_STOPPED when its PID file is gone. The backup directory remains for inspection; port 5432 must remain available.