Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA13580; Thu, 17 Dec 92 12:31:48 -0800
Date: Thu, 17 Dec 92 12:31:48 -0800
Message-Id: <9212172031.AA13580@postgres.Berkeley.EDU>
From: jdc@kendrick.cse.nau.edu (John Campbell)
Subject: Moving database directories
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu


In the Postgres User Manual, the following section is presented
(section 9.2 in my manual):
   
   Moving database directories out of $POSTGRESHOME/data/base
   
   By default, all databases are stored in separate  subdirec-
   tories under $POSTGRESHOME/data/base(1).  To move a particular 
   data base to an  alternate directory (e.g., on a filesystem with 
   more free space), do the following:
   
   +    Create the database (if it doesn't already exist) using
        the  createdb  command.  In the following steps we will
        assume the database is named foo.
   
   +    Copy the directory $POSTGRESHOME/data/base/foo and its
        contents to its ultimate destination. It should still 
        be owned by the postgres user.
   
   +    Remove the directory $POSTGRESHOME/data/base/foo.
   
   +    Make a symbolic link in $POSTGRESHOME/data/base to the 
        new directory.
   
   ____________________
   
      [1]Data for certain classes may  stored  elsewhere  if  a
   non-standard storage manager was specified when they were
   created.
   
I have tried this and do not believe it works.   Postgres wants
to open files in the parent (..) directory, but (..) won't work after 
you've followed a sym-link.

Here's what I have in my parent directory:

   PG_VERSION	pg_database	pg_log		pg_time
   base		pg_defaults	pg_magic	pg_user
   pg.debug	pg_demon	pg_server	pg_variable
   
The error message that I get, from the postgres back end, is
that it can't open pg_log.  From the front end I get the message
that the version isn't right (and a query asking if I've run
createdb).

The best I believe you can do is 1) make a sym-link for all of
~postgres/data to some other partition (which works nicely--that's
what I'm doing) or 2) make a sym-link as described above and copy
the .. files to the parent of the new sym-link.  The second method,
however, causes at least pg_user problems.

A possible solution might be to have both POSTGRESHOME and POSTGRESDATA
environment variables and not use .. if POSTGRESDATA is defined.  This
would, I believe, allow the manual instructions above to work.

-- 
	John Campbell               John.Campbell@nau.edu
        jdc@sunset.cse.nau.edu      JDC@NAUVAX.UCC.NAU.EDU
