Tuesday, July 11, 2006

PostgreSQL backup and restore

Senario: Backup database dz-demo on 192.168.1.112 owner postgres to dz-enx-3 on 192.168.1.72 owner doczadm.

(192.168.1.112)
#su - postgres
$pg_dump -Ft --blobs --oids dz-demo | gzip > /tmp/dz.tar.gz
or
$pg_dump -Ft -b -o dz-demo | gzip > /tmp/dz.tar.gz

ftp dz.tar.gz to /tmp of 192.168.1.72
#gunzip /tmp/dz.tar.gz
(192.168.1.72)
#su - doczadm
$dropdb dz-enx-3
$createdb dz-enx-3
$pg_restore -d dz-enx-3 -O -U doczadm -x /tmp/dz.tar

Done.

No comments: