How to Backup and Restore PostgreSQL Databases Using pgAdmin

In PostgreSQL, users can create multiple databases with different purposes and create multiple tables within each database. However, in databases, there is always a possibility of losing the stored data. Therefore, database experts recommend creating backup files of these databases to restore them in case of any accidents like deletion of the database, etc.

This post demonstrates how to back up and restore PostgreSQL databases in pgAdmin.

How to Backup and Restore a Postgres Database Using pgAdmin?

To backup and restore PostgreSQL databases using pgAdmin, follow this simple guide using these basic steps:

Step 1: Backup PostgreSQL Database

To create a backup of the PostgreSQL database, open the pgAdmin application from the local system:

img

Type the Master password and click on the “OK” button to connect to the PostgreSQL servers:

img

Select the database and right-click on it from the mouse to expand the options menu containing the “Backup…” button:

img

Clicking on the “Backup…” button will direct the user to the Backup window so from there click on the folder icon from the filename tab:

img

Select the folder in which the backup file will be stored, type the name of the backup file with its type, and click on the “Save” button:

img

Once the folder and file name is selected, simply click on the “Backup” button:

img

The backup has been created successfully as the process has been finished successfully:

img

Step 2: Delete PostgreSQL Database

After creating a backup of the database, the user can always recover a database in case of its deletion accidentally. To delete the database, simply right-click on the database and click on the “Delete/Drop” button:

img

Click on the “Yes” button to confirm its deletion:

img

Step 3: Create PostgreSQL Database

After the deletion of the database, the user needs to create a database and then restore the backup file of the database. To create a database, simply right-click on the “Databases” button and click on the “Database…” button from the “Create” menu:

img

Create a database by typing its name in the Database tab and click on the “Save” button to complete the creation of the database:

img

Step 4: Restore PostgreSQL Database

Once the database is created on the PostgreSQL server, simply right-click on the database and click on the “Restore…” button:

img

Select the format of the file and provide the complete address of the file from the local system before clicking on the “Restore” button:

img

The process of restoring a PostgreSQL database from a backed-up file has been successfully completed:

img

That’s all about backing up and restoring PostgreSQL databases using pgAdmin.

Conclusion

To back up and restore the PostgreSQL database, open the pgAdmin application from the computer and create a backup of the database. To create a backup of the database, it is required to provide the format of the backup and its location on the local system. After that, delete the database and then recreate another database using pgAdmin on the computer. Restore the PostgreSQL database from the backup file located in the local system.