Re: Command to reset entire PgSQL cluster?

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Felipe Gasper <felipe(at)felipegasper(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Command to reset entire PgSQL cluster?
Date: 2015-02-10 19:06:16
Message-ID: 20150210140616.1ba78ebc17b7e4258ff112fd@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 10 Feb 2015 13:02:05 -0600
Felipe Gasper <felipe(at)felipegasper(dot)com> 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.

Without more details, I can't be sure that this will work for you, but
it seems like you should be able to simply drop/create the database
that the tests use to rebuild the environment, since most things
associated with a test environment will be destroyed when the
database is dropped. There are some exceptions, such as roles and
users, but I wouldn't think you would need to wipe/recreate those.

In any event, don't know if that suggestion will help, but it's
what was successful for me.

--
Bill Moran

In response to

Browse pgsql-general by date

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