Skip site navigation (1) Skip section navigation (2)

Re: Moving data directory

From: Ray Stell <stellr(at)cns(dot)vt(dot)edu>
To: Linux Geeks <indolinux(dot)geeks(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Moving data directory
Date: 2007-05-14 00:02:59
Message-ID: 20070514000259.GA28681@cns.vt.edu (view raw or flat)
Thread:
Lists: pgsql-admin
On Sat, May 12, 2007 at 11:47:46PM +0700, Linux Geeks wrote:
> I'm very new to postgresql and would like to move my data directory to
> another partition in Ubuntu. 


I don't think there is anything internal to pg that locks the data
location.  Just tell postmaster where you move it to.  Shut down the
postmaster and move it and start it with the -D flag pointing to the
new location:

$  pg_ctl start -D /var/pgsql/data
server starting

$ psql -p 5437 testdb jira
Password for user jira: 
Welcome to psql 8.2.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

testdb=> \q

pg_ctl stop -D /var/pgsql/data     
waiting for server to shut down....,7222,,2007-05-13 19:52:06.675 EDT,,1,,, LOG:  logger shutting down
 done
server stopped

$ mv /var/pgsql/data-move-test /var/pgsql/data   

$  pg_ctl start -D /var/pgsql/data-move-test
server starting

$ psql -p 5437 testdb jira                    
Password for user jira: 
Welcome to psql 8.2.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

testdb=> \q

pg_ctl stop -D /var/pgsql/data-move-test                             
waiting for server to shut down....,7245,,2007-05-13 19:55:00.944 EDT,,1,,, LOG:  logger shutting down
 done
server stopped

$ mv /var/pgsql/data-move-test /var/pgsql/data 

$  pg_ctl start -D /var/pgsql/data
server starting

$ psql -p 5437 testdb jira                                   
Password for user jira: 
Welcome to psql 8.2.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

testdb=> \q

-- 
  Lost time is when we learn nothing from the experiences of life. Time
 gained is when we grow to have a wisdom that is tested in the reality of life.

In response to

Responses

pgsql-admin by date

Next:From: Anu Gupta DCSADate: 2007-05-14 04:07:20
Subject: A Study on Free/Open Source Software Defect Management
Previous:From: Peter EisentrautDate: 2007-05-13 17:17:55
Subject: Re: Moving data directory

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group