pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_restore usage
3+ messages / 2 participants
[nested] [flat]

* pg_restore usage
@ 2004-06-21 21:57  Thomas F. O'Connell <tfo@alumni.brown.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: tfo@alumni.brown.edu @ 2004-06-21 21:57 UTC (permalink / raw)
  To: pgsql-admin

A while back, there was a thread on this list called "pg_restore
problem with 7.3.1". It outlined a scenario very similar to one I'm
having problems with. Granted, they're not serious problems (in the
sense that there's an acceptable workaround), but they suggest that
either pg_restore is not working as expected, or I have incorrect
expectations. I'd like to get some clarification as to which is the
case.

I dump a database as follows:

pg_dump -F c db >pg_dump`date +\%Y\%m\%d`.pgsql

I transfer this file to another server, where the database db does not
exist. I try the following:

pg_restore -C -d db pg_dump20040621.pgsql

I get this error:

pg_restore: [archiver (db)] connection to database "db" failed: FATAL:
 database "db" does not exist

What is an example of how the -C flag is intended to be used? If it is
omitted, then the error is the same because no createdb has been
issued.

In the end, what I'm looking for is a nice way of taking a dump and
restoring it in one command that could be added to a crontab. I
realize that it's not too much extra work to create a shell script
that creates the relevant database, but this seems like such a natural
one-liner, and I'm curious what the intent of the -C flag is, if not
to precipitate such a situation.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_restore usage
@ 2004-06-27 14:22  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas F. O'Connell <tfo@alumni.brown.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2004-06-27 14:22 UTC (permalink / raw)
  To: tfo@alumni.brown.edu; +Cc: pgsql-admin

tfo@alumni.brown.edu (Thomas F. O'Connell) writes:
> I transfer this file to another server, where the database db does not
> exist. I try the following:

> pg_restore -C -d db pg_dump20040621.pgsql
> pg_restore: [archiver (db)] connection to database "db" failed: FATAL:
>  database "db" does not exist

> What is an example of how the -C flag is intended to be used?

Whatever database you name in -d has to already exist, because that's
where pg_restore will initially connect.  -C means to issue a CREATE
DATABASE command and then reconnect to the new db.

In other words, try "-C -d template1".

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_restore usage
@ 2004-06-28 19:55  Thomas F. O'Connell <tfo@alumni.brown.edu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: tfo@alumni.brown.edu @ 2004-06-28 19:55 UTC (permalink / raw)
  To: pgsql-admin

So these two statements seem to be somewhat contradictory.

What's the point of -C if not to create the database named in -d?

And why does -C -d template1 work but not -C -d <mypgsql>?

-tfo

tgl@sss.pgh.pa.us (Tom Lane) wrote in message news:<11767.1088346148@sss.pgh.pa.us>...
> Whatever database you name in -d has to already exist, because that's
> where pg_restore will initially connect.  -C means to issue a CREATE
> DATABASE command and then reconnect to the new db.
> 
> In other words, try "-C -d template1".



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-06-28 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-21 21:57 pg_restore usage Thomas F. O'Connell <tfo@alumni.brown.edu>
2004-06-27 14:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-06-28 19:55   ` Thomas F. O'Connell <tfo@alumni.brown.edu>

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