Search code examples
postgresqlpg-dump

PostgreSQL: Database backup and Recovery?


What is the procedure to take database backup and recovery in PostgreSQL 9.3?

I am using SQL Dump for the same, but getting an error near pg_dump.

--Example

pg_dump testdb > backupfile

--Error occurred

ERROR:  syntax error at or near "pg_dump"  
LINE 1: pg_dump testdb > backupfile  

Solution

  • Use below command to take Database backup locally

    pg_dump -U postgres -h 127.0.0.1 -p 5432 -Fc -f FileName.backup -w DBName
    

    If you want to take database backup remotely Than use Remote IPAddress in place of 127.0.0.1.