Re: [GENERAL] Can I backup/restore a database in a sql script?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: [GENERAL] Can I backup/restore a database in a sql script?
Date: 2007-06-22 09:09:39
Message-ID: 467B91D3.60300@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Joost Kraaijeveld wrote:
> Hi,
>
> I want to write a sql script in which I backup a database and restore
> a new (altered) version of that database. Is that possible? If so ,
> can anyone give me an example of how to do that?
>
> I can run it from any command prompt (psql -U postgres template1 <
> my_db.backup) but I would like it to run from psql (which should
> give me 1 script for all platforms I must do this: Windows, FreeBSD
> and Debian)

You can restore using just psql (because pg_dump can produce an sql file
to be processed). I don't know of any way to backup a database that
doesn't use pg_dump.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message davood khoshfetrat 2007-06-22 11:16:38 big tables in postgres and sub records.
Previous Message Vishal Arora 2007-06-22 08:43:15 Re: back up maintenance schedule

Browse pgsql-general by date

  From Date Subject
Next Message Teodor Sigaev 2007-06-22 09:18:53 Re: Regression - Query requires full scan, GIN doesn't support it
Previous Message David Goodenough 2007-06-22 08:42:18 Regular express question