How to backup PostgreSQL database?

kumkumsharma

Administrator
Staff member
If you want to install latest version of PostgreSQL then first you have to take backup of your database and then try to install or update database.

To take backup it is must to have access of root user, you can follow below steps:
  • Login via SSH
  • You can run below command to take backup of your database:
Code:
pg_dumpall -U postgres > db.out
Important: Here db.out is database backup file.
  • For the previous version ofdatabase you have to move your PostgreSQL directory. You can run below command:
Code:
service postgresql stop
mv /var/lib/pgsql /var/lib/directory_file_name
Here directory_file_name represents your directory name.
 
Top