Re: Fixing the loss of 'template1' - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Fixing the loss of 'template1'
Date
Msg-id 201203070710.31656.adrian.klaver@gmail.com
Whole thread Raw
In response to Fixing the loss of 'template1'  (Martin Gregorie <martin@gregorie.org>)
List pgsql-general
On Wednesday, March 07, 2012 6:23:42 am Martin Gregorie wrote:

>
> Question
> ========
> Is it possible to reinstate 'template1' and all its works without
> reinitialising the database from scratch. It was suggested to me that
> running "initdb" might fix it while leaving my data in place though my
> source was uncertain about its success. Would this work or is there a
> better way to restore 'template1' in a populated database system?

So the question is, did you have your template1 customized in the 8.4
installation and are you looking to transfer those added items to the 9.1
installation?  Some information on the template system can be found here:

http://www.postgresql.org/docs/9.1/interactive/manage-ag-templatedbs.html

As others have said you can recreate a bare template1 from template0.  If you
had not customized template1 that should do.  If you had customized it:

On the chance that the 8.4 cluster is still up and running you could just do a
pg_dump of template1 on that cluster and load it into the new cluster. If the
8.4 cluster is not running you can go to your pg_dumpall file and get the
template1 objects from there. Search for the  \connect template1 string and look
for the SQL commands until the next \connect string.


>
>
> Martin

--
Adrian Klaver
adrian.klaver@gmail.com

pgsql-general by date:

Previous
From: Andy Colson
Date:
Subject: rounding a timestamp to nearest x seconds
Next
From: Tom Lane
Date:
Subject: Re: ERROR: could not find tuple for trigger 37463634