Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA17064; Tue, 28 Jan 92 11:06:19 -0800
Message-Id: <9201281906.AA17064@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: moving databases to other filesystems
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Fri, 24 Jan 92 06:11:16 PST."
             <9201241411.AA23447@postgres.Berkeley.EDU> 
Date: Tue, 28 Jan 92 11:06:06 PST

you write:

>I have trouble moving a Postgres database to a new location.
> 
>What I do:
>1) createdb tdnmo
>2) cd ~postgres/data/base
>3) mv tdnmo tdnmo.old
>4) ln -s tdnmo.old tdnmo
> 
>Step 3) and 4) are to test if symlinking works.
>I can do: monitor -c "retrieve (pg_user.all)" tdnmo
> 
>without any problems.
> 
>Now I try to move the files to the another filesystem on Magneto Optical disc:
> 
>5) su root
>6) mkdir /u/eos/postgres_db
>7) tar cf - tdnmo.old | (cd /u/eos/postgres_db; tar xvf -)
>8) rm tdnmo
>9) ln -s /u/eos/postgres_db/tdnmo.old tdnmo
> 
>I have checked all ownerships and filemodes but 
> 
>monitor -c "retrieve (pg_user.all)" tdnmo
> 
>NOTICE:Jan 24 14:04:33:InitStdio: !ValidPgVersion
>FATAL 1:Jan 24 14:04:33:Did you run createdb on tdnmo yet??
> 
> What is wrong ????

The problem is that when the backend starts up it does a chdir to the
database directory.  Due to the symlink you have created this amounts
to changing the process's working directory to /u/eos/postgres_db/tdnmo.old.
So far so good.  Now however, when the backend needs to look for certain
installation wide relations or meta data it will look 2 directories up.
Of course /u/eos/postgres_db/tdnmo.old/../.. does not contain these
relations or data.  The error message you are getting results from not
finding the PG_VERSION file which lives in $POSTGRESHOME/data, but other
problems will occur later if this test is passed.  Namely it won't be able
to find pg_log, pg_user, pg_variable etc.... basically anything that normally
lives two directories up will apparently be missing to the backend.

Note also in the first case you cite the database directory was still two
levels below the $POSTGRESHOME/data directory.

Jeff Meredith
mer@postgres.berkeley.edu
