From: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: Can I backup/restore a database in a sql script? |
Date: | 2007-06-22 08:13:09 |
Message-ID: | 200706221113.10105.achill@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-general |
Στις Παρασκευή 22 Ιούνιος 2007 10:59, ο/η Joost Kraaijeveld έγραψε:
> 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)
>
With "\!" you can execute shell commands.
So you could probably
\c template1
\! pg_dump your_db > your_db.sql
\! some_processing your_db.sql > your_db_altered.sql
DROP DATABSE your_db
CREATE DATABSE your_db
\i your_db_altered.sql
I dont know if the \! escape works for windows, and in any case pg_dump,
some_processing programs must be in the PATH for Unix/Windows
Debian/FreeBSD behaviour is exactly the same, it is on windows that you should
try to make it work.
> TIA
>
> Joost
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
--
Achilleas Mantzios
From | Date | Subject | |
---|---|---|---|
Next Message | Vishal Arora | 2007-06-22 08:43:15 | Re: back up maintenance schedule |
Previous Message | Joost Kraaijeveld | 2007-06-22 07:59:24 | Can I backup/restore a database in a sql script? |
From | Date | Subject | |
---|---|---|---|
Next Message | EBIHARA, Yuichiro | 2007-06-22 08:20:54 | Re: standard LOB support |
Previous Message | Joost Kraaijeveld | 2007-06-22 07:59:24 | Can I backup/restore a database in a sql script? |