Re: Command to reset entire PgSQL cluster?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Felipe Gasper <felipe(at)felipegasper(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Command to reset entire PgSQL cluster?
Date: 2015-02-10 19:08:32
Message-ID: 54DA5730.3020308@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/02/2015 19:02, Felipe Gasper wrote:
> On 2/10/15 12:57 PM, David G Johnston wrote:
>> Felipe Gasper wrote
>>> Is there a quick way to reset a PgSQL cluster to its pristine
>>> state--i.e., to what initdb gives but preserving configuration
>>> customizations?
>>
>> Not that I am aware of.
>>
>> If you describe your use-case then meaningful suggestions could be
>> offered.
>>
>
> We have a lot of code that tests interaction with a PgSQL cluster on the
> same server that has a live production cluster. To keep the testing
> environment separate from production, we create a PgSQL cluster in a
> temp directory then run tests against that.
>
> This, as you can imagine, is pretty expensive to set up each time …
> initdb is not fast! It would be nice if we could just create a single
> test PgSQL cluster then wipe it clean at the end of each test.

How about this? -

- Create your new, pristine cluster.
- Stop the PG server.
- Make a filesystem copy of the data directory to somewhere else.
- Restart the server.

Then, when you want to restore the cluster to its pristine state, you
could just stop the server, delete the data directory, restore it from
the copy made above, then restart the server. You'd need to make sure
that permissions were correct.

Mind you, I've never found initdb particularly slow...

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2015-02-10 19:10:12 Re: Command to reset entire PgSQL cluster?
Previous Message Adrian Klaver 2015-02-10 19:07:11 Re: Command to reset entire PgSQL cluster?