Command to reset entire PgSQL cluster?

Started by Felipe Gasperabout 11 years ago8 messagesgeneral
Jump to latest
#1Felipe Gasper
felipe@felipegasper.com

Hello,

Is there a quick way to reset a PgSQL cluster to its pristine
state--i.e., to what initdb gives but preserving configuration
customizations?

Thank you!

-FG

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Felipe Gasper (#1)
Re: Command to reset entire PgSQL cluster?

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.

David J.

--
View this message in context: http://postgresql.nabble.com/Command-to-reset-entire-PgSQL-cluster-tp5837399p5837400.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Felipe Gasper
felipe@felipegasper.com
In reply to: David G. Johnston (#2)
Re: Command to reset entire PgSQL cluster?

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.

-FG

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4John R Pierce
pierce@hogranch.com
In reply to: Felipe Gasper (#1)
Re: Command to reset entire PgSQL cluster?

On 2/10/2015 10:49 AM, 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?

backup the .conf file(s), initdb, restore the .conf files.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Bill Moran
wmoran@potentialtech.com
In reply to: Felipe Gasper (#3)
Re: Command to reset entire PgSQL cluster?

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Felipe Gasper (#1)
Re: Command to reset entire PgSQL cluster?

On 02/10/2015 10:49 AM, Felipe Gasper wrote:

Hello,

Is there a quick way to reset a PgSQL cluster to its pristine
state--i.e., to what initdb gives but preserving configuration
customizations?

Something like:

cp -r /pgdata to pgdata_bak/ at initial state.

When you want to reset cp -r pgdata_bak/ pgdata/

Thank you!

-FG

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

In reply to: Felipe Gasper (#3)
Re: Command to reset entire PgSQL cluster?

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@iol.ie

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#8John R Pierce
pierce@hogranch.com
In reply to: Felipe Gasper (#3)
Re: Command to reset entire PgSQL cluster?

On 2/10/2015 11:02 AM, 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.

use a file system, like zfs, that supports snapshots. initdb the
first time, configure your system, then snapshot it. each successive
time, stop postgres, revert the snapshot, restart postgres.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general