Thread: pg_restore error

pg_restore error

From
"Curtis Mortensen"
Date:
I've tried searching the archives for a solution to this, but I was unable
to find it.  So, I hope you'll forgive my newbie question if it's been asked
before.  I'm trying to backup a database on our company's server.  First I
create the backup (pg_dump [databasename] > backup.dump) then I create a new
database [databasename2].  When I try to move the dump to the new database
(pg_restore [databasenam2] < backup.dump) it gives me this error:

pg_restore: [archiver] could not open input file: No such file or directory

I get the same even if I give the absolute path for backup.dump.  I assume
that postgres is looking somewhere else for my file, but being fairly new to
SQL, I don't know where that is or where to find out.  So, any help or hints
you could give me would be appreciated.

Thanks,

Curtis Mortensen


Re: pg_restore error

From
Giles Lean
Date:
Curtis Mortensen asked:

> When I try to move the dump to the new database
> (pg_restore [databasenam2] < backup.dump) it gives me this error:
>
> pg_restore: [archiver] could not open input file: No such file or directory

To specify the database name to restore to, you want the --dbname option:

$ pg_restore --dbname=databasenam2 < backup.dump

Regards,

Giles

Re: pg_restore error

From
Giles Lean
Date:
Hi Curtis,

> thanks for the advice.  i now have a different error. :(

I suspected you would, but without knowing the commands you were using
decided guessing would only be confusing!  Only the archive formats
from pg_dump are intended to be used with pg_restore.  The default
output can be restored by psql:

$ pg_dump fubar > fubar.sql
$ createdb fubar2
CREATE DATABASE
$ psql fubar2 < fubar.sql
You are now connected as new user giles.
CREATE
$

$ pg_dump --format=c fubar > fubar.dump
$ createdb fubar2
CREATE DATABASE
$ pg_restore --dbname=fubar2 < fubar.dump
pg_restore: [archiver] WARNING:
  Data restoration may fail because existing triggers cannot be disabled
  (no superuser user name specified).  This is only a problem when
  restoring into a database with already existing triggers.
$

Regards,

Giles


Re: pg_restore error

From
"Curtis Mortensen"
Date:
I finally got a chance to try out your suggestions, but it seems that something I'm doing is still wrong.
 
When I try the first method described below, I get this error:
 
You are now connected as new user postgres.
ERROR:  function plpgsql_call_handler already exists with same argument types
ERROR:  Language plpgsql already exists
\connect: FATAL 1:  IDENT authentication failed for user "cmortensen"
 
When I try the other method, I get this error:
 
pg_restore: [archiver (db)] could not execute query: ERROR:  function plpgsql_call_handler already exists with same argument types
 
I get the impression that the problem is deeper than just trying to backup, but being a very green novice to Postgres, I'm not sure where to start tracking the problem to its source...
 
Thanks for all your help so far :)
-------- Original Message --------
Hi Curtis,

> thanks for the advice.  i now have a different error. :(

I suspected you would, but without knowing the commands you were using
decided guessing would only be confusing!  Only the archive formats
from pg_dump are intended to be used with pg_restore.  The default
output can be restored by psql:

$ pg_dump fubar > fubar.sql
$ createdb fubar2
CREATE DATABASE
$ psql fubar2 < fubar.sql
You are now connected as new user giles.
CREATE
$

$ pg_dump --format=c fubar > fubar.dump
$ createdb fubar2
CREATE DATABASE
$ pg_restore --dbname=fubar2 < fubar.dump
pg_restore: [archiver] WARNING: Data restoration may fail because existing triggers cannot be disabled (no superuser user name specified).  This is only a problem when restoring into a database with already existing triggers.
$

Regards,

Giles

Re: pg_restore error

From
"Curtis Mortensen"
Date:

In case anyone else was following my problem and wanted to know how to resolve it, I'll post what the solution was...

I had a bunch of '/connect user' commands in my dump file causing the ident authentication errors.  I took those out and the plpgsql stuff that I didn't need in the dump, and that restored everything fine to a new database, except that none of my web applications could get in.  That was when i realized that I'd left out the authorization stuff in pg_hba.conf.  When I added that, everything worked great.

-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Curtis Mortensen
Sent: Monday, September 09, 2002 3:55 PM
To: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] pg_restore error

I finally got a chance to try out your suggestions, but it seems that something I'm doing is still wrong.
 
When I try the first method described below, I get this error:
 
You are now connected as new user postgres.
ERROR:  function plpgsql_call_handler already exists with same argument types
ERROR:  Language plpgsql already exists
\connect: FATAL 1:  IDENT authentication failed for user "cmortensen"
 
When I try the other method, I get this error:
 
pg_restore: [archiver (db)] could not execute query: ERROR:  function plpgsql_call_handler already exists with same argument types
 
I get the impression that the problem is deeper than just trying to backup, but being a very green novice to Postgres, I'm not sure where to start tracking the problem to its source...
 
Thanks for all your help so far :)
-------- Original Message --------
Hi Curtis,

> thanks for the advice.  i now have a different error. :(

I suspected you would, but without knowing the commands you were using
decided guessing would only be confusing!  Only the archive formats
from pg_dump are intended to be used with pg_restore.  The default
output can be restored by psql:

$ pg_dump fubar > fubar.sql
$ createdb fubar2
CREATE DATABASE
$ psql fubar2 < fubar.sql
You are now connected as new user giles.
CREATE
$

$ pg_dump --format=c fubar > fubar.dump
$ createdb fubar2
CREATE DATABASE
$ pg_restore --dbname=fubar2 < fubar.dump
pg_restore: [archiver] WARNING: Data restoration may fail because existing triggers cannot be disabled (no superuser user name specified).  This is only a problem when restoring into a database with already existing triggers.
$

Regards,

Giles