pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
restoring from a dump
3+ messages / 3 participants
[nested] [flat]

* restoring from a dump
@ 2013-01-05 20:54  J Rouse <jrouse@capecod.net>
  0 siblings, 1 reply; 3+ messages in thread

From: J Rouse @ 2013-01-05 20:54 UTC (permalink / raw)
  To: pgsql-admin

Stupid person here.  Just got PostgresSQL today.  Have text dump file.  Need 
to restore.

I think I need to use psql, but do not even know how to get to it.  Need 
exact instructions on where to enter the command line, setting up paths if 
necessary, etc.

Jim



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



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

* Re: restoring from a dump
@ 2013-01-06 19:48  CS DBA <cs_dba@consistentstate.com>
  parent: J Rouse <jrouse@capecod.net>
  0 siblings, 1 reply; 3+ messages in thread

From: CS DBA @ 2013-01-06 19:48 UTC (permalink / raw)
  To: pgsql-admin

On 1/5/13 1:54 PM, J Rouse wrote:
> Stupid person here.  Just got PostgresSQL today.  Have text dump 
> file.  Need to restore.
>
> I think I need to use psql, but do not even know how to get to it.  
> Need exact instructions on where to enter the command line, setting up 
> paths if necessary, etc.
>
> Jim
>
>
>
to restore from a text (sql) file:

1) ensure you have a target database:
- you might need to set your path, i.e. you need to know where psql is
- if you did an rpm / package install it's probably in /usr/bin

# connect to the cluster (database instance):
$ psql

# then create your target database:
postgres# create database my_target_db;

Then exit from psql (exit; or ctl-d)
postgres# exit;



2) import the sql text file

- cd to the directory where the text file is:
$ cd /home/postgres/Downloads

- Import the file
$ psql  -ef   ./import_file.sql   my_target_db


You could also point to the sql file without being in the directory:
$ psql  -ef   /home/postgres/Downloads/import_file.sql my_target_db



Note the -f is the psql flag to import (or run) a specified sql file 
from the command line, the -e flag says to push all SQL statements as 
well as normal output to STDOUT


See the psql command docs for more info here:

http://www.postgresql.org/docs/9.2/interactive/app-psql.html



Hope this helps,

/Kevin







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



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

* Re: restoring from a dump
@ 2013-01-07 13:11  Burgholzer, Robert (DEQ) <Robert.Burgholzer@deq.virginia.gov>
  parent: CS DBA <cs_dba@consistentstate.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Burgholzer, Robert (DEQ) @ 2013-01-07 13:11 UTC (permalink / raw)
  To: pgsql-admin

The other quick item to consider is whether or not your database is on a *nix system or a windows machine, and if your workstation is *nix or windows.  

Cases/suggestions:
1. Windows workstation / *nix DB Server: use putty.exe to ssh into the DB server (a second option would be to use PGAdmin, a GUI db management package for PostgreSQL)
2. Windows workstation / Windows DB Server: use CMD.com and enter psql command line (may have to add "C:/Program Files/PostgreSQLX.YY/bin" to your PATH).  Could also use PGAdmin in this case
3. *nix client / *nix server: command line psql (ssh to server if not the same as your workstation)



________________________________________
From: pgsql-admin-owner@postgresql.org [pgsql-admin-owner@postgresql.org] on behalf of CS DBA [cs_dba@consistentstate.com]
Sent: Sunday, January 06, 2013 2:48 PM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] restoring from a dump

On 1/5/13 1:54 PM, J Rouse wrote:
> Stupid person here.  Just got PostgresSQL today.  Have text dump
> file.  Need to restore.
>
> I think I need to use psql, but do not even know how to get to it.
> Need exact instructions on where to enter the command line, setting up
> paths if necessary, etc.
>
> Jim
>
>
>
to restore from a text (sql) file:

1) ensure you have a target database:
- you might need to set your path, i.e. you need to know where psql is
- if you did an rpm / package install it's probably in /usr/bin

# connect to the cluster (database instance):
$ psql

# then create your target database:
postgres# create database my_target_db;

Then exit from psql (exit; or ctl-d)
postgres# exit;



2) import the sql text file

- cd to the directory where the text file is:
$ cd /home/postgres/Downloads

- Import the file
$ psql  -ef   ./import_file.sql   my_target_db


You could also point to the sql file without being in the directory:
$ psql  -ef   /home/postgres/Downloads/import_file.sql my_target_db



Note the -f is the psql flag to import (or run) a specified sql file
from the command line, the -e flag says to push all SQL statements as
well as normal output to STDOUT


See the psql command docs for more info here:

http://www.postgresql.org/docs/9.2/interactive/app-psql.html



Hope this helps,

/Kevin







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


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



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


end of thread, other threads:[~2013-01-07 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-01-05 20:54 restoring from a dump J Rouse <jrouse@capecod.net>
2013-01-06 19:48 ` CS DBA <cs_dba@consistentstate.com>
2013-01-07 13:11   ` Burgholzer, Robert (DEQ) <Robert.Burgholzer@deq.virginia.gov>

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