Re: Restoring from SQL dump - Mailing list pgsql-novice

From Erin Jonaitis
Subject Re: Restoring from SQL dump
Date
Msg-id 00e801cecc12$7feb5590$7fc200b0$@wisc.edu
Whole thread Raw
In response to Re: Restoring from SQL dump  (Ken Benson <ken@infowerks.com>)
Responses Re: Restoring from SQL dump  (Michael Swierczek <mike.swierczek@gmail.com>)
List pgsql-novice

Thanks, Ken, this was helpful.

 

I tried to follow Anathasios’ advice about setting the path variable, but on Windows7 this seems a bit opaque; I did add my PostgreSQL \bin directory to the Path variable through Control Panel (and I’ve checked my spelling three times), but I still have to be in that directory to run the program, strangely. So Ken’s example here, of how to give a full pathname for a command that isn’t in one of the %path% directories, is super useful.

 

What wound up working for me is somewhat similar:


“C:\Program Files\PostgreSQL\9.3\bin\psql” –U[username] [targetDB]”

 

This got me into the DB into which I want to restore the dump. And then once in psql, I used the command

 

\i ‘[dbfilespace]/[dumpname]’

 

To import it. (I say “it worked” optimistically because it is actually doing something, but there’ve been some periods where that “something” is “hanging” so we’re not out of the woods yet.)

 

Glad there is a list for n00bs. Thanks for the quick responses. I’ll try to pay it forward someday, once I know what I’m doing.

 

Erin

 

From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Ken Benson
Sent: Friday, October 18, 2013 9:28 AM
To: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Restoring from SQL dump

 

From the command prompt - I've successfully used:

"C:\Program Files\PostgreSQL\9.1\bin\pg_restore" -h {serverIP} -U {UserID} -C -d {targetDB} M:\LongitudinalDB\backups\2013.10.02\uw.sql



But, if you use "C:\Program Files\PostgreSQL\9.1\bin\pg_restore" --help
... at a command prompt, you'll get some more help.

Of course, you need to make sure your installation is in this location...


Ken Benson


On 10/18/2013 7:22 AM, Erin Jonaitis wrote:

Thanks, all. I did also try this from the Windows command prompt -- it gave
me the standard error it gives when it has no idea what you're talking
about: "'psql' is not recognized as an internal or external command,
operable program or batch file." Any Windows PostgreSQL users present?
 
Erin
 
-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of David Johnston
Sent: Friday, October 18, 2013 9:19 AM
To: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Restoring from SQL dump
 
Erin Jonaitis wrote
3)      Now I have a psql window open with the following prompt: 
dbname=#
 
4)      I tried typing the following:
psql -f M:\LongitudinalDB\backups\2013.10.02\uw.sql
and got the following error:
Invalid command \LongitudinalDB. Try \? For help.
 
#3 - you are now in psql
#4 - you are acting as if you are sitting at your OS shell prompt here
 
Either learn the psql to run an external file or get back to your OS shell
prompt and run the psql command from there.
 
Not sure why you did't get more errors.
 
Yes, backslashes inside psql denote the intent to use a special command
which "Long..." is not.
 
David J.
 
 
 
 
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Restoring-from-SQL-dump-tp5775028p57
75031.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
 
 
--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 
 
 

 

pgsql-novice by date:

Previous
From: Ken Benson
Date:
Subject: Re: Restoring from SQL dump
Next
From: Michael Swierczek
Date:
Subject: Re: Restoring from SQL dump