5

I’m attempting my first upgrade of Postgres from 9.3 to 9.5. I’ve run into two roadblocks but not sure how to get around them. I have my 9.3 PGDATA set to /data/postgres, which is a separate filesystem on my RHEL 6 server. After installing 9.5 and running initdb, I attempted to run pg_upgrade using this command line:

/usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.3/bin -B /usr/pgsql-9.5/bin 
  -d /data/postgres -D /var/lib/pgsql/9.5/data --link -p 5432 -P 5433 -c

This command failed the link parameter test, because the 9.5 PGDATA value is not on the same filesystem as 9.3. Roadblock #1.

I then tried to re-initialize 9.5 using this command:

initdb -D /data/postgres95

It errored saying "Data directory is not empty!". Roadblock #2.

How do I proceed with this upgrade? I’d rather not move to a new server.

1

Self-answer from Kevin Struckhoff originally left as a comment:

Finally got back to this task and ran the upgrade successfully.

Turns out, since I use tablespaces in specific directories, the new 9.5 are right next to the old 9.3 dirs:

drwx------ 4 postgres postgres  4096 Oct  4  2014 PG_9.3_201306121
drwx------ 3 postgres postgres  4096 Apr 18 11:49 PG_9.5_201510051
0

Are you sure /data/postgres95 is empty?

If there's nothing of value in there, then run

PG95=/data/postgres95
sudo rm -rf $PG95
mkdir $PG95
chown postgres:postgres $PG95
su - postgres -c 'PGDATA=/data/postgres95; initdb

Then run pg_upgrade again the same way but with -D /data/postgres95 instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.