How to backup Postgresql database..??

How to backup Postgresql database..??

backup postgresql database

Today you will learn how to backup postgresql database and restore Postgresql.. We will use pg_dump command to create a dump of the postgresql database..

Backup Postgresql

Read Also: How to install postgresql on centos?

In this step we will take backup of the postgresql databases use the following command to take backup,  i am using postgres user to take backup and i am taking backup of ‘installvirtual‘ database

pg_dump -U postgres installvirtual > installvirtual.sql

This command will make a dump of postgresql database

Or, if you want to take backup of all databases use following syntax

pg_dumpall > alldatabases.sql

Read Also: How to install glusterfs on centos?

Restore Postgresql Database

psql -U postgres -d installvirtual -f installvirtual.sql

Restore all databases

psql -f alldatabases.sql

Read Also: How to install rabbitmq on centos?

Now we can easily take backup and restore  postgresql databases.

If you have any issue using this tutorial feel free to comment below

Read Also: Basic docker commands

 

Consider sharing this article: