Skip to content

Instantly share code, notes, and snippets.

@Alextrapixel
Created September 13, 2025 13:35
Show Gist options
  • Save Alextrapixel/43f8759965ea60c633ce2ad645c0daaf to your computer and use it in GitHub Desktop.
Save Alextrapixel/43f8759965ea60c633ce2ad645c0daaf to your computer and use it in GitHub Desktop.
Restore PostgreSQL database that backed-up using pgadmin4

If you have a .backup file from pgAdmin4, then it can be restored using pg_restore.

Use this command to restore : pg_restore -h <your_db_host> -U <your_db_user> -d <your_db_name> /backup/mydb.backup

This is the example of using the command: pg_restore -h 172.17.0.1 -U postgres -d mydb /backup/mydb.backup

You can get your host IP using this : hostname -I


Optional

You can create a backup using this command

pg_dump -h <your_db_host> -U <your_db_user> -F c -d <your_db_name> -f /backup/mydb.backup

pg_dump -h 172.17.0.1 -U postgres -F c -d mydb -f /backup/mydb.backup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment