Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I restore a .sql file backup in pgadmin

I have a .sql file of the database backup. PostgreSQL is installed in my system and I use pgadmin4 to communicate with database. I want to restore this .sql file using pgadmin. Can someone please guide me.

like image 955
Akshay Kale Avatar asked Oct 25 '25 08:10

Akshay Kale


1 Answers

An SQL script that was generated with pg_dump without the --inserts option cannot be restored with pgAdmin, because the COPY data are mixed with the statements. You need psql for that.

You could use one of the other backup formats ("custom", "directory" or "tar") and use pgAdmin to restore that. But all that pgAdmin does in this case is call pg_restore, so you might as well do that yourself from the command line.

Another option is to launch the "psql tool" from pgAdmin, which is nothing else than psql. Then you can load the dump with \i dumpfile.sql.

like image 134
Laurenz Albe Avatar answered Oct 26 '25 22:10

Laurenz Albe