PostgreSQL Logical Backup & Restore

2.Logical Backup


  1. dump backup  
  2. dumpall backup  //full backup

1.Dump Backup use pg_dump Utility:

su - postgres
cd /usr/pgsql-11/bin

pg_dump Options:
-h    hostname
-p    port number
-d    database name
-t     table name
-F    format
        p   plain format  (filename=filename.sql)
        c   custom format (filename=filename.dump or filename.dmp)
        t    tar format  (filename=filename.tar)
        d   directory format (filename=filename)

./pg_dump -h localhost -p 5432 -d postgres -t emp -Fp -f /backup/emp.sql

Dump Restore:

Plain format Restore:

./psql -h localhost -p 5432 -d db2 -f /backup/emp.sql     //plain

Custom, tar, directory format Restore:

./pg_restore -h localhost -p 5432 -d db2 -f /backup/emp.dump  //c,t,d

2.Dump All Backup use pg_dumpall Utility:

su - postgres
cd /usr/pgsql-11/bin

Backup Command:

./pg_dumpall -h 192.168.1.21 -p 5432 -f /backup/emp.sql

Restore Command:

./psql -h localhost -p 5433 -f /backup/emp.sql

Comments

Popular posts from this blog

PostgreSQL pg_pool-II Installation and Configuration

PostgreSQL Migration Using MTK

PostgreSQL Pages and Tuples