Restoring pg_dump Backup with psql Fails - Mailing list pgsql-admin

From Phillip Smith
Subject Restoring pg_dump Backup with psql Fails
Date
Msg-id 003501c849b1$95ed1200$9b0014ac@wbaus090
Whole thread Raw
Responses Re: Restoring pg_dump Backup with psql Fails
List pgsql-admin
PostgreSQL 8.2.4 on RedHat ES4 64-bit

Hi all,

Doing some works on a database this morning (changing it to take data from
our new ERP system) so naturally I made a backup of the database first:
      pg_dump important_database > ~/backup/important-071229.sql
    chmod 440 ~/backup/important-071229.sql

Of course things have screwed up (fortunately no-one is working today) and I
need to restore:
      psql
    ALTER DATABASE important_database RENAME TO
important_database071229;
    CREATE DATABASE important_database;
    \q

    psql important_database < ~/backup/important-071229.sql

But I get a whole bunch of errors, for example:
<snip>
ERROR:  syntax error at or near "all"
LINE 1: all orders over $400.00 - freight free Order 10 of any produ...
        ^
ERROR:  syntax error at or near "If"
LINE 1: If stores spend over $300.00 they will receive a 5% discount...
<snip>
invalid command \.
invalid command \.
invalid command \N
invalid command \N
<snip>

Both psql and pg_dump are the correct versions:
    [postgres@stirling ~]$ ls -lh `which pg_dump`
    lrwxrwxrwx  1 root root 31 Jul 25 11:51 /usr/local/bin/pg_dump ->
/usr/local/pg-8.2.4/bin/pg_dump
    [postgres@stirling ~]$ ls -lh `which psql`
    lrwxrwxrwx  1 root root 28 Jul 25 11:51 /usr/local/bin/psql ->
/usr/local/pg-8.2.4/bin/psql
(I compile each new version of Postgres to it's own folder and data dir:
/usr/local/pg-<version>/ and /home/Postgres/pgData-<version> )

What am I doing wrong?

Cheers,
~p

Phillip Smith
IT Coordinator
Weatherbeeta P/L
8 Moncrief Rd
Nunawading, VIC, 3131
AUSTRALIA


THINK BEFORE YOU PRINT - Save paper if you don't really need to print this

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments
e-mail.

pgsql-admin by date:

Previous
From: "Usama Dar"
Date:
Subject: Re: Fresh copy of a PG DB ?
Next
From: Tom Lane
Date:
Subject: Re: Restoring pg_dump Backup with psql Fails