To backup the entire PostgreSQL database directory
Just copy the '/var/lib/postgres/8.x/main' folder to some safe place (backup drive) using the command of
$ cp -rp /var/lib/postgresql/8.4/main /Data/postgres
(or)
$ rsync -avz /var/lib/postgresql/8.4/main /Data/postgres
This will backup the entire PostgreSQL data into the folder path called '/Data/postgres'
To restore the backed-up Data folder
Backed-up data folder of PostgreSQl can be restored in any system and also the target PostgreSQL instance could be a new or old one.
- Just edit '/etc/postgresql/8.4/main/postgresql.conf' and change the 'data_directory' to our new path called '/Data/postgres/main'.
- Restart the postgres once. (If it shows 'its already running' error, then kill the postgres process and do the start again)
Note: This is tested under Ubuntu 10.04 and 11.04 with PostgreSQL 8.x
No comments:
Post a Comment