Re: restoring a database to its initial state - Mailing list pgsql-general

From Manlio Perillo
Subject Re: restoring a database to its initial state
Date
Msg-id 4B9FA063.1060305@gmail.com
Whole thread Raw
In response to Re: restoring a database to its initial state  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Lane ha scritto:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
>> 2010/3/13 Manlio Perillo <manlio.perillo@gmail.com>:
>>> Usually when I need to restore a database to its initial state, what I
>>> do is to simply drop it, and then re-create it.
>>> However on a shared hosting this is not possible.
>
>> Usually people use a install and a uninstall scripts. First creates
>> dbobjects, second removes objects.
>
> "pg_dump --clean" can help with creating an uninstall script.
>

The problem is that it is not possible to *just* having pg_dump generate
the SQL statement for database cleanup.

I was thinking to write a simple Python script for the job.
It will read objects from the pg_catalog, having an associated owner:

 pg_class, pg_conversion, pg_database, pg_language, pg_namespace,
 pg_opclass, pg_operator, pg_opfamily, pg_proc, pg_tablespace,
 pg_ts_config, pg_ts_dict, pg_type

For each object the script will issue an appropriate DROP CASCADE statement.

Is this correct?


Thanks  Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkufoGIACgkQscQJ24LbaUT3EgCghRQy4BdYtaGAXNE0Mx1gj0LT
mdgAoIiRPvgEdUy+STDhfoppgz9MRQVZ
=3uye
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Daylight savings time confusion
Next
From: Frank jansen
Date:
Subject: Re: Move to core xml from contrib/xml2