Home Tutorials Restore a PostgreSQL backup

Restore a PostgreSQL backup

Last updated on Jan 31, 2024

Restore the Database

Use pg_restore to restore the database. Make sure to exclude the public schema and restore into your newly created database. Open a terminal and run:

export PGPASSWORD=<YOUR PASSWORD>'; pg_restore -h <YOUR_HOST> -U <YOUR_USER> -d <YOUR_DATABASE> -v --no-acl --no-owner --exclude-schema=public path/to/your/backup_file.backup
  • The --no-acl and --no-owner flags ensure that the access control and ownership settings from the backup file are not applied.

  • The --exclude-schema option to exclude the "public" schema during the restore process for security reasons.