Re: restoring a database to its initial state

From: Manlio Perillo <manlio(dot)perillo(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: restoring a database to its initial state
Date: 2010-03-16 15:14:43
Message-ID: 4B9FA063.1060305@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Lane ha scritto:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> 2010/3/13 Manlio Perillo <manlio(dot)perillo(at)gmail(dot)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-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Frank jansen 2010-03-16 15:39:14 Re: Move to core xml from contrib/xml2
Previous Message Alvaro Herrera 2010-03-16 15:11:59 Re: Daylight savings time confusion