Re: Problem with pg_restore into new database

Поиск
Список
Период
Сортировка
От Mr. John
Тема Re: Problem with pg_restore into new database
Дата
Msg-id 535883.19656.qm@web45508.mail.sp1.yahoo.com
обсуждение исходный текст
Ответ на Problem with pg_restore into new database  ("Mr. John" <mr_johnmr@yahoo.com>)
Ответы Re: Problem with pg_restore into new database  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
tanks for reply.

Why should I connect to a existing database to restore another one ?
from documentation,pg_restore seems to can do this :
http://www.postgresql.org/docs/8.0/interactive/app-pgrestore.html
-C
--create

Create the database before restoring into it. (When this option is used, the database named with -d is used only to issue the initial CREATE DATABASE command. All data is restored into the database name that appears in the archive.)

in my first attempt was no -d,no error and ... NO database
@echo off
 "pg_restore.exe"  -h 192.168.1.1 -p 5432 -U postgres  -C -v "stru.tar"   2>>log_resto.txt
 echo %errorlevel% >err_resto.txt

log file is :
pg_restore: creating DATABASE _struct_fis_
pg_restore: connecting to new database "_struct_fis_"
pg_restore: creating SCHEMA pos
pg_restore: creating SCHEMA public
pg_restore: creating COMMENT SCHEMA public
pg_restore: creating PROCEDURAL LANGUAGE plpgsql
............................




From: Richard Huxton <dev@archonet.com>
To: Mr. John <mr_johnmr@yahoo.com>
Cc: pgsql-general@postgresql.org
Sent: Monday, November 17, 2008 11:31:28 AM
Subject: Re: [GENERAL] Problem with pg_restore into new database

Mr. John wrote:
> but on the server is no database called _struct_fis_
> err_resto.txt file contents only "0".
>
> If I add    -d
> @echo off
>  "pg_restore.exe"  -h 192.168.1.1 -p 5432 -U postgres -d "_struct_fis_" -C -v "stru.tar"  2>>log_resto.txt
>  echo %errorlevel% >err_resto.txt
>
> error is "1" and log file  :
>
>    pg_restore: connecting to database for restore
> pg_restore: [archiver (db)] connection to database "_struct_fis_" failed: FATAL:  database "_struct_fis_" does not exist
> pg_restore: *** aborted because of error

I'm not sure I understand your problem fully, but this is because you
are trying to connect (-d ...) to database _struct_fis_ before it's
created. Connect to a database you know exists (template1 or postgres
for example) and then let the restore create the database.


--
  Richard Huxton
  Archonet Ltd

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

В списке pgsql-general по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: aggregates and case statements
Следующее
От: "Grzegorz Jaśkiewicz"
Дата:
Сообщение: Re: disable/enable trigger and transaction