Tuesday, October 29, 2013

Moving Postgresql Data Folder

We had a old server which ran out space for partition where postgres was running… we had to move the data folder to a bigger partition… and here is how I did it…
Step 0:  Stop the Postgres if running
$service postgresql stop
Step 1 :  Copy  the whole  data/  folder  to  new parition
say  we have  /usr/local/pgsql/data   and wants to move to /home2/ partition
$cp -R /usr/local/pgsql/data  /home2/postgres/data
Step 2 :  Modify the Startup script to point to correct data directory
In  /etc/init.d/postgresql  file,  change the value of  PGDATA  variable to new location  which is /home2/postgres/data
Step 3 : Start the db server
$ service postgresql start

No comments:

Post a Comment