pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Finner <frank@finner.de>
To: Martín Marqués <martin@bugs.unl.edu.ar>
Cc: PGSQL <pgsql-php@postgresql.org>
Cc: arun kv <arun@library.iisc.ernet.in>
Subject: Re: backup postgres database
Date: Sun, 17 Mar 2002 23:54:15 +0100 (CET)
Message-ID: <XFMail.020317235415.frank@finner.de> (raw)
In-Reply-To: <20020313220401.82428FCA2@bugs.unl.edu.ar>

Hi Martin!

Ah, stupid me, you are right. Even if one has ALL create statements
within the dump, including the "create database", one must connect to a
database to be able to run the commands within the dump. 

If in doubt, which database to use, one should always be able to
connect to database "template1" without great possibilities to damage
something (except one connects as user postgres) and run the dumped
commands, because "template1" is always there in a postgres
installation. But please be sure not to insert your tables into
template1, because everything what is in this database is used as
template for every new database! Just use it as a "connection database"
and run some commands similiar to

Create Database "my_db";
\connect my_db my_username

as the first commands of the dump (this is what "pg_dump -C <my_db>"
gives you)! 

Another reason to carefully study the manpages... ;-)

Greetings, Frank.



On 13-Mar-02 Martín Marqués sat down, thought for a long time and then
wrote:
> On Mié 13 Mar 2002 15:51, you wrote:
>> Hi,
>>
>> pg_dump and psql are your friends.
>>
>> Dump the database with pg_dump, take the file and insert it into
>> psql
>> on the other machine. Details are covered in the manpages of these
>> programs.
>>
>> Crude (without options): pg_dump your_db > your_db.dump
>>                          psql < your_db.dump
> 
> This will almost always give an error (even though lots of docs have
> this 
> sintaxis). That's because you didn't tell psql which database to
> connect to, 
> so he'll try to connect to a database with the name of the user (in
> my case, 
> that would be martin, or postgres in the case of administration
> duties).
> 
> My 2 cents
> 
> -- 
> Porqué usar una base de datos relacional cualquiera,
> si podés usar PostgreSQL?
> -----------------------------------------------------------------
> Martín Marqués                  |        mmarques@unl.edu.ar
> Programador, Administrador, DBA |       Centro de Telematica
>                        Universidad Nacional
>                             del Litoral
> -----------------------------------------------------------------
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org

--
Frank Finner

And now there is no turning back at all.
                              (M. Moorcock, "Elric Of Melnibone")"



view thread (11+ messages)

Message-ID: <XFMail.020317235415.frank@finner.de>
Permalink:  ../XFMail.020317235415.frank@finner.de/
Also on:    postgresql.org/message-id/XFMail.020317235415.frank@finner.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: frank@finner.de, martin@bugs.unl.edu.ar, arun@library.iisc.ernet.in
  Subject: Re: backup postgres database
  In-Reply-To: <XFMail.020317235415.frank@finner.de>
  References: <20020313220401.82428FCA2@bugs.unl.edu.ar> <XFMail.020317235415.frank@finner.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox