From: CS DBA <cs_dba@consistentstate.com>
To: pgsql-admin@postgresql.org
Subject: Re: restoring from a dump
Date: Sun, 06 Jan 2013 12:48:23 -0700
Message-ID: <50E9D507.7040506@consistentstate.com> (raw)
In-Reply-To: <E8FDFB478C244E18ACA2B509B6CF1726@RC201204>
References: <E8FDFB478C244E18ACA2B509B6CF1726@RC201204>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: cs_dba@consistentstate.com
Subject: Re: restoring from a dump
In-Reply-To: <50E9D507.7040506@consistentstate.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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