Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:49:01+00:00 2026-06-04T12:49:01+00:00

I have been working to upgrade a Postgresql database from 8.4 to 9.1. I

  • 0

I have been working to upgrade a Postgresql database from 8.4 to 9.1. I have encountered innumerable problems (may have to do with Ubuntu’s file placements), but I think I see the finish line.
Pg_upgrade is almost working, but it fails when it reaches the first database, ‘template0,’ because it ‘already exists.’

psql:/var/lib/postgresql/pg_upgrade_dump_globals.sql:36: ERROR:  database "template0" already exists

There were problems executing "/usr/lib/postgresql/9.1/bin/psql" --set ON_ERROR_STOP=on --no-psqlrc --port 5432 --username "postgres" -f "/var/lib/postgresql/pg_upgrade_dump_globals.sql" --dbname template1 >> "/dev/null"
Failure, exiting

This template0 database is of course part of every new cluster and can not be deleted. I tried renaming template0 and template1 (to be safe) on the new cluster (after recreating it), but the subsequent pg_upgrade call also failed, but this time complaining that template1 didn’t exist on the new cluster.

"/usr/lib/postgresql/9.1/bin/pg_ctl" -w -l "/dev/null" -D "/var/lib/postgresql/9.1/main" -o "-p 5432 -b" start >> "/dev/null" 2>&1

connection to database failed: FATAL:  database "template1" does not exist

unable to connect to new postmaster started with the command: "/usr/lib/postgresql/9.1/bin/pg_ctl" -w -l "/dev/null" -D "/var/lib/postgresql/9.1/main" -o "-p 5432 -b" start >> "/dev/null" 2>&1
Failure, exiting

I tried it again only renaming template0 and it failed again, but this time with some assertion issue from postgres itself.

executing: SELECT datcollate, datctype FROM     pg_catalog.pg_database WHERE    datname = 'template0' 

pg_upgrade: /build/buildd/postgresql-9.1-9.1.3/build/../contrib/pg_upgrade/check.c:310: set_locale_and_encoding: Assertion `PQntuples(res) == 1' failed.
Aborted (core dumped)

Sanity Check Notes: In case anyone thinks ‘just do a full sql dump and restore it’ that isn’t working well either, which is why I am trying to get pg_upgrade working. I also made sure to drop and recreate the cluster every time an upgrade failed to prevent any relics of failures past from continuing to screw with the upgrade. The database is on an Amazon Volume, so I can’t really break anything and always have a backup. I am on ubuntu 12 and have both databases installed side by side.

I am currently out of ideas that doesn’t involve going into the postgresql source and would greatly appreciate any help and suggestions as to what to try next. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:49:02+00:00Added an answer on June 4, 2026 at 12:49 pm

    Stop. Make a cup of tea / coffee and sit down.

    1. Make sure you have 9.1 and 8.4 installed at the same time. Debian allows this, so presumably ubuntu does too.
    2. Using the 9.1 version of pg_dump, dump each of your databases from 8.4, and either a dumpall for the users or just manually recreate them.
    3. Using 9.1 pg_restore, restore your databases as user postgres along with the –create flag.

    If there are specific problems with any of these steps you’ll need to make a note of them and provide details. Oh – the best place for detailed step-by-step advice is probably the postgresql-general mailing list (see the website for details). You can take your time there and get each step right.

    At a guess you’re trying to do the pg_upgrade into an existing initdb-ed directory which I don’t think it expects. In any case, dump+restore is the cleanest way to do this – it also gives you a backup copy of your DB too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on an upgrade to Rails 3.1 from 2.3.11. One of
I have been working on a BlackBerry application that consumes web services from ColdFusion
I have been getting some weird errors when I upgrade jQuery from 1.4.4 to
Have been working on this question for a couple hours and have come close
I have been working on Eclipse recently. I am fairly new to java programming,
I have been working on a Windows Mobile app for a little while now
I have been working on keeping things object oriented for my project. Currently, I'm
I have been working on this problem for 2 days now and it's an
I have been working on a django app on my local computer for some
I have been working with Exceptions lately. I think it makes sense to log

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.