How to restore PostgreSQL databases using .tar /.sql file via SSH?

Started by Dipak Bhoi, February 21, 2015, 02:21:22 PM

Previous topic - Next topic

Dipak Bhoi

Hello folks,

You can restore PostgreSQL databases using .tar & .sql file via command line. There is two separate commands to handle this restoration. To restore PostgreSQL databases using .tar file there is a command called pg_restore. To restore PostgreSQL databases using .sql file you need to use psql command.

Restore PostgreSQL databases using .tar file :

Quote#pg_restore -c -i -U username -d database_name -v "/home/username/public_html/myfile.tar"

EX: #pg_restore -c -i -U postgres -d kalidat_wpdb -v "/home/kalidat/public_html/backupdb.tar"

Parameters description:-

-c for cleaning the database,
-i to ignore any database version checks,
-U to force a user,
-d to select the database &
-v verbose mode.


Restore PostgreSQL databases using .sql file :

Quote#psql -U user-name -d database_name -f filename.sql

EX: psql -U postgres -d kalidat_wpdb -f /home/kalidat/public_html/backupdb.sql

Parameters description:-

-U to force a user,
-d to select the destination database &
-f to select source file.


That's all, Hope you like this post..

Enjoy !!!!!! :)


MilesWeb - 30-Day Money Back
cPanel Web Hosting - cPanel Hosting in India
Grab a Free SSL for your website.  WordPress Optimized Solution.