Introduction

PostgreSQL is a robust, open-source object-relational database system known for its extensibility and adherence to standards. Among its many features, backup and restore functionalities are essential for database maintenance and disaster recovery. This guide walks you through the process of backing up and restoring a PostgreSQL database using pgAdmin, a popular GUI tool for PostgreSQL.

PostgreSQL database

Prerequisites

Before we dive into the steps, ensure you have the following.

Backup Using pgAdmin

Backing up a PostgreSQL database using pgAdmin involves creating a backup file that contains the data and schema of the database. Here’s how to do it:

Step 1. Open pgAdmin and Connect to Your Database Server.

  1. Launch pgAdmin.
  2. Connect to your PostgreSQL server by right-clicking on the server name and selecting Connect Server.
    Connect Server

Step 2. Navigate to the Database.

  1. In the browser panel on the left, expand the server and navigate to the database you want to back up.
  2. Right-click on the database and select Backup.
    Backup Menu Image

Step 3. Configure Backup Options.

1. General Tab

General Tab Image

2. Data Options Tab (Optional)

Data Options Tab

3. Query OptionsTab (Optional)

Query Options Image

4. Table Options Tab (Optional)

Table Options Tab

5. Options Tab (Optional)

Options Tab Image

6. Objects Tab

Here you can choose a whole public folder that will have all your tables, procedures, functions, etc, or you can choose a specific table or others as per your requirement.

Objects Tab Image

Step 4. Execute the Backup.

Restore Using pgAdmin

Restoring a PostgreSQL database involves loading data from a backup file into a database. Here’s how to restore using pgAdmin:

Step 1. Open pgAdmin and Connect to Your Database Server.

Step 2. Create a New Database (If Necessary).

Step 3. Navigate to the Target Database.

Step 4. Configure Restore Options.

1. General Tab

Filename: Specify the path to the backup file (e.g., /path/to/backup/your_database.backup).

Note. Select All Files(*.*) if you have not found your Backup file.

Restore General Tab

2. Restore Options (Optional)

Restore Data Options Tab Image

Restore Query Options Tab Image

Restore Table Options Tab Image

Restore Options Tab Image

Step 5. Execute the Restore.

In the above Image, there is only a "public" folder already exists and must be the owner of the schema public error indication as they are already inside our "Article_Renew" Database. Other than those all commands Ran successfully.

Conclusion

Using pgAdmin to manage backups and restores of your PostgreSQL databases is a straightforward and efficient process. Regular backups are crucial to ensure data safety and continuity in case of any issues. By following this guide, you can back up and restore your PostgreSQL databases, safeguarding your data against potential loss.