…technology, business, technology in business, business in technology … and more

Moving postgres data folder

Our postgres server ran out of disk space on our EC2 server so we figured we should move the postgres data folder to a new bigger volume. We created an additional volume mounted to /disk2 and then moved the data folder as follows -

1. Login to shell as root. Stop the Postgres if running

$service postgresql-9.0 stop

2. Copy the data folder to new location

$cp -R /var/lib/pgsql/9.0/data  /disk2/pgdata/

3. Modify postgres startup script to point to new data directory

In  /etc/init.d/postgresql  file,  change the value of  PGDATA  variable to new location  which is /disk2/pgdata/data

4. Start the db server

$ service postgresql start

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.