Backup & restore PostgreSQL database with phpPgAdmin

phpPgAdmin is a web-based administration tool for PostgreSQL written in PHP and based on the popular phpMyAdmin interface originally written for MySQL administration. Website developers can use this free database tool to backup and restore PostgreSQL databases easily. Exporting PostgreSQL database also allows you to save a backup of it from remote server to local computer, or import it into another server or account. In this tutorial we will walk you through the quick steps to backup and restore PostgreSQL databases in cPanel using phpPgadmin. Note that phpPgadmin is only available when you or your hosting service provider installed it on the server. It is usually pre-installed on shared Linux servers, such as Inmotion web hosting, Bluehost. We will use shared web hosting with Inmotion in this demo.

Backup PostgreSQL database with phpPgAdmin

Login to cPanel, scroll down to the Databases section, find and click phpPgAdmin icon.

cpanel databases inmotion

The phpMyAdmin opens in a new web browser tab and you will be connected to the PostgreSQL server automatically. On the left pane, you can see a list of all PostgreSQL databases. Click the name of the database to select it. You will then get a page like this.

Backup PostgreSQL database with phpPgAdmin

Click Export button at the top right corner. Choose the format you want to export. You can choose Data only, Structure only or both Structure and data. We recommend you creating a full backup by selecting Structure and data in the Format column. Then choose Download or Download compressed with gzip in the Options section. Finally click the Export at the bottom. Your web browser may present you a warning about the download. Click Allow to start downloading the PostgreSQL database from server to your computer through the web browser. Once the downloading finishes, open the Downloads folder in File Explorer on PC or Find on Mac to find this database file either in sql or gzip format depending on the option you selected in the export process.

Create PostgreSQL databases in cPanel

You must create a PostgreSQL database before you can restore or import a PostgreSQL backup file. We have explained how you can create PostgreSQL databases in cPanel here. If the new database has not been created yet, refer to previous linked page for more details.

Restore PostgreSQL database using phpPgAdmin

Again, head to cPanel > Databases > phpPgAdmin. Click to select the new PostgreSQL database you want to import the backup into from the left pane. Click to open SQL tab on the right hand side. Here you can see a big SQL box where you can enter SQL script to execute. Click Choose File button below this SQL box, then browse to and choose the database backup file.

Restore PostgreSQL database using phpPgAdmin

Click the Execute button to begin the import process. This will take some time depending on the database backup file size. When you see a SQL Executed message, you are finished.


Leave a Reply