HeadlinesBriefing favicon HeadlinesBriefing.com

Restoring PostgreSQL on AWS Without Direct DB Access

DEV Community •
×

In well-designed AWS infrastructure, a PostgreSQL server sits in a private subnet without a public IP, inaccessible via SSH. Access is routed through a jump host (bastion host). This guide explains restoring a database from a local `.sql` file, analyzing different approaches for secure, professional recovery.

The primary challenge is that GUI tools like DBeaver often fail with complex scripts requiring superuser privileges, such as creating extensions or altering owners. The recommended solution uses an SSH tunnel with port forwarding, connecting your local `psql` client directly to the private database server through the jump host.

Alternative methods include temporarily granting superuser status to the application user or copying the SQL file to the server for local execution. The article also details how to choose the correct restore command—`psql` for plain-text dumps versus `pg_restore` for custom-format backups—emphasizing that proper tool selection is critical for a successful recovery.