Thread: how to use pg_dump and then restored onto development server

how to use pg_dump and then restored onto development server

From
ketan shah
Date:

Hi,

 All ,

  I am newbie to postgres database. How to take pg_dump from production database and restore into development server using pg_restore..

From documentation, I find that I have to use pg_dump for backup and pg_restore for restoration.

My database name is otsdb..

 For backup…I use command

    Pg_dump otsdb > /home/Ketan/otsdbbkp.out

 But after successfully dump…I can’t see the otsdbbkp.out file in /home/Ketan/

 If I get otsdbbkp.out file then I copy this file on my development server and then I issue the following command …

 Psql –d otsdb –f otsdbbkp.out

 (my development server database name is otsdb)

 pl. help me….

 If any thing wrong pl. guide me..

 Ketan shah

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: how to use pg_dump and then restored onto development server

From
"Zlatko Matic"
Date:
Concerning this question about pg_dump, I'm also confused and don't understand when to use pg_restore and when to use psql ?
For example, how to restore in these two cases:
A) pg_dump -f D:\MYDB_BCP -c -x -h localhost -U postgres MYDB
B) pg_dump -f D:\MYDB_BCP -Fc -c -x -h localhost -U postgres MYDB
 
Thanks.
----- Original Message -----
Sent: Wednesday, June 29, 2005 4:48 PM
Subject: [GENERAL] how to use pg_dump and then restored onto development server

Hi,

 All ,

  I am newbie to postgres database. How to take pg_dump from production database and restore into development server using pg_restore..

From documentation, I find that I have to use pg_dump for backup and pg_restore for restoration.

My database name is otsdb..

 For backup…I use command

    Pg_dump otsdb > /home/Ketan/otsdbbkp.out

 But after successfully dump…I can’t see the otsdbbkp.out file in /home/Ketan/

 If I get otsdbbkp.out file then I copy this file on my development server and then I issue the following command …

 Psql –d otsdb –f otsdbbkp.out

 (my development server database name is otsdb)

 pl. help me….

 If any thing wrong pl. guide me..

 Ketan shah

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: how to use pg_dump and then restored onto development server

From
Douglas McNaught
Date:
ketan shah <ketan_dba@yahoo.com> writes:

> Hi,
>
>  All ,
>
>   I am newbie to postgres database. How to take pg_dump from production
> database and restore into development server using pg_restore..
>
> From documentation, I find that I have to use pg_dump for backup and
> pg_restore for restoration.
>
> My database name is otsdb..
>
>  For backup*I use command
>
>  Pg_dump otsdb > /home/Ketan/otsdbbkp.out
>
>  But after successfully dump*I can*t see the otsdbbkp.out file in
> /home/Ketan/

Do you get any error messages?

>  If I get otsdbbkp.out file then I copy this file on my development server
> and then I issue the following command *
>
>  Psql *d otsdb *f otsdbbkp.out

Are those really asterisks rather than dashes?

What error message do you get?

-Doug

Re: how to use pg_dump and then restored onto development server

From
Douglas McNaught
Date:
"Zlatko Matic" <zlatko.matic1@sb.t-com.hr> writes:

> Concerning this question about pg_dump, I'm also confused and don't
> understand when to use pg_restore and when to use psql ?
> For example, how to restore in these two cases:
> A) pg_dump -f D:\MYDB_BCP -c -x -h localhost -U postgres MYDB
> B) pg_dump -f D:\MYDB_BCP -Fc -c -x -h localhost -U postgres MYDB

If you use any of the binary dump formats (-Fc or -Ft), use
pg_restore.  For text dumps (the default) use psql.

-Doug

Re: how to use pg_dump and then restored onto development server

From
"Zlatko Matic"
Date:
OK..i get it. It works...
My additional question is: how to incorporate timestamp in dumped file name
?
Let's say, if we have script: pg_dump -f D:\MYDB_BCP -Fc -c -x -h
localhost -U postgres MYDB,
so that output file is named something like MYDB_BCP_2005-29-01, for
example. Is that possible?
Thanks.

----- Original Message -----
From: "Douglas McNaught" <doug@mcnaught.org>
To: "Zlatko Matic" <zlatko.matic1@sb.t-com.hr>
Cc: "ketan shah" <ketan_dba@yahoo.com>; <pgsql-general@postgresql.org>
Sent: Wednesday, June 29, 2005 5:29 PM
Subject: Re: [GENERAL] how to use pg_dump and then restored onto development
server


> "Zlatko Matic" <zlatko.matic1@sb.t-com.hr> writes:
>
>> Concerning this question about pg_dump, I'm also confused and don't
>> understand when to use pg_restore and when to use psql ?
>> For example, how to restore in these two cases:
>> A) pg_dump -f D:\MYDB_BCP -c -x -h localhost -U postgres MYDB
>> B) pg_dump -f D:\MYDB_BCP -Fc -c -x -h localhost -U postgres MYDB
>
> If you use any of the binary dump formats (-Fc or -Ft), use
> pg_restore.  For text dumps (the default) use psql.
>
> -Doug
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq


Re: how to use pg_dump and then restored onto development server

From
Douglas McNaught
Date:
"Zlatko Matic" <zlatko.matic1@sb.t-com.hr> writes:

> OK..i get it. It works...
> My additional question is: how to incorporate timestamp in dumped file
> name ?
> Let's say, if we have script: pg_dump -f D:\MYDB_BCP -Fc -c -x -h
> localhost -U postgres MYDB,
> so that output file is named something like MYDB_BCP_2005-29-01, for
> example. Is that possible?

I'm sure it's possible, but I'm not an expert on Windows batch command
language.  There are some good references for that stuff on the
web--check them out.

-Doug

Re: how to use pg_dump and then restored onto development server

From
Matt Van Mater
Date:
On 6/29/05, Douglas McNaught <doug@mcnaught.org> wrote:
> "Zlatko Matic" <zlatko.matic1@sb.t-com.hr> writes:
>
> > OK..i get it. It works...
> > My additional question is: how to incorporate timestamp in dumped file
> > name ?
> > Let's say, if we have script: pg_dump -f D:\MYDB_BCP -Fc -c -x -h
> > localhost -U postgres MYDB,
> > so that output file is named something like MYDB_BCP_2005-29-01, for
> > example. Is that possible?
>
> I'm sure it's possible, but I'm not an expert on Windows batch command
> language.  There are some good references for that stuff on the
> web--check them out.
>

To get the date in a format that should work for you in win2000 and
winxp, open a command prompt and type the following command:
FOR /F "tokens=2-4 delims=/ " %f IN ('date /t') DO (echo %h-%g-%f)

To get the same date format inside a .bat batch script, replace each %
sign with two % signs, like this:
FOR /F "tokens=2-4 delims=/ " %%f IN ('date /t') DO (echo %%h-%%g-%%f)

You can run a similar command to get the current timestamp as well.
For more information on how to do this, and to better understand the
commands above, open a command prompt and type "for /?"... you will
see a help screen on the FOR construct in the windows command shell.

enjoy:)

Matt

Re: how to use pg_dump and then restored onto development server

From
"Zlatko Matic"
Date:
thanks.

----- Original Message -----
From: "Matt Van Mater" <matt.vanmater@gmail.com>
To: "Zlatko Matic" <zlatko.matic1@sb.t-com.hr>
Cc: <pgsql-general@postgresql.org>
Sent: Thursday, June 30, 2005 7:25 PM
Subject: Re: [GENERAL] how to use pg_dump and then restored onto development
server


On 6/29/05, Douglas McNaught <doug@mcnaught.org> wrote:
> "Zlatko Matic" <zlatko.matic1@sb.t-com.hr> writes:
>
> > OK..i get it. It works...
> > My additional question is: how to incorporate timestamp in dumped file
> > name ?
> > Let's say, if we have script: pg_dump -f D:\MYDB_BCP -Fc -c -x -h
> > localhost -U postgres MYDB,
> > so that output file is named something like MYDB_BCP_2005-29-01, for
> > example. Is that possible?
>
> I'm sure it's possible, but I'm not an expert on Windows batch command
> language.  There are some good references for that stuff on the
> web--check them out.
>

To get the date in a format that should work for you in win2000 and
winxp, open a command prompt and type the following command:
FOR /F "tokens=2-4 delims=/ " %f IN ('date /t') DO (echo %h-%g-%f)

To get the same date format inside a .bat batch script, replace each %
sign with two % signs, like this:
FOR /F "tokens=2-4 delims=/ " %%f IN ('date /t') DO (echo %%h-%%g-%%f)

You can run a similar command to get the current timestamp as well.
For more information on how to do this, and to better understand the
commands above, open a command prompt and type "for /?"... you will
see a help screen on the FOR construct in the windows command shell.

enjoy:)

Matt