Instalation batch file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Instalation batch file

Zlatko Matic
Hello.
 
I would like to install database schema on a server using  files with dumped schema and globals (produced by dumpall), that are placed on CD. The installation script (batch file) that restores these two files is also placed on the same CD, (let's say E:) in the same folder.
 
cd C:\Program Files\PostgreSQL\8.0\bin
psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
vacuumdb -d MYBASE -U zmatic
But, what if CD is F: or some other unit ? 
How could I change this batch file (Windows XP) to be able to recognize what is the actual path of the folder that containes these three files ?
 
Thanks in advance,
 
Zlatko
Reply | Threaded
Open this post in threaded view
|

Re: Instalation batch file

Glenn Davy
On Wed, 2005-08-03 at 23:29 +0200, Zlatko Matić wrote:

> Hello.
>  
> I would like to install database schema on a server using  files with
> dumped schema and globals (produced by dumpall), that are placed on
> CD. The installation script (batch file) that restores these two files
> is also placed on the same CD, (let's say E:) in the same folder.
>  
> cd C:\Program Files\PostgreSQL\8.0\bin
> psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
> psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
> vacuumdb -d MYBASE -U zmatic
>
> But, what if CD is F: or some other unit ?  
> How could I change this batch file (Windows XP) to be able to
> recognize what is the actual path of the folder that containes these
> three files ?

Im not sure how to determine the path to the media (esp if more than one
cd/dvd), but you could take a couple of different approaches:
1)that is to run the script from the cd drive and build the path to pg's
bin with %HOMEDRIVE%. Type 'SET' to see what other shell variables
there are
2) Run the script from anywhere and take %1 type command line paramaters
to ask location of either bin and/or cd/dvd

Been years since I've had the misfortune to have to use windows shell
scipts, but there are prob many other approachs - best to do a little
research into windows shell scripting and determine best for your
scenario.

Glenn
>  
> Thanks in advance,
>  
> Zlatko


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org
Reply | Threaded
Open this post in threaded view
|

Re: Instalation batch file

SCassidy
In reply to this post by Zlatko Matic

Hi,

If the psql program is always going to be in C:\Program
Files\PostgreSQL\8.0\bin, couldn't you eliminate the "cd", and just specify
the full path (if psql is not in the current PATH) as needed?  Or, add it
to the PATH:    PATH %path%;C:\Program Files\PostgreSQL\8.0\bin

If you running the .bat file from the CD, you won't have to know the drive
letter.

E.g.:

psql -f MYBASE_SHEMA.dumpall template1 -U zmatic
psql -f MYBASE_SHEMA.dumpall template1 -U zmatic
vacuumdb -d MYBASE -U zmatic

You could add the path for psql if you need to.  E.g.:

@ECHO off

if exist test_path.pl GOTO foundit
echo "placing psql in path"
PATH %path%;C:\Program Files\PostgreSQL\8.0\bin

:foundit
echo "now doing the psql"

 ...   then continue with your psql commands.


Hope this helps.


Susan


                                                                                                                                           
                           Zlatko Matić                                                                                                    
                      <[hidden email]-com        To:       <[hidden email]>                                              
                      .hr>                           cc:                                                                                  
                           Sent by:                  Subject:  [GENERAL] Instalation batch file                                            
                                                                                                                                           
                                                      |-------------------|                                                                
                      pgsql-general-owner@pos         | [ ] Expand Groups |                                                                
                      tgresql.org                     |-------------------|                                                                
                                                                                                                                           
                                                                                                                                           
                           08/03/2005 02:29                                                                                                
                      PM                                                                                                                  
                                                                                                                                           
                                                                                                                                           




Hello.

I would like to install database schema on a server using  files with
dumped schema and globals (produced by dumpall), that are placed on CD. The
installation script (batch file) that restores these two files is also
placed on the same CD, (let's say E:) in the same folder.

cd C:\Program Files\PostgreSQL\8.0\bin
psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
vacuumdb -d MYBASE -U zmatic
But, what if CD is F: or some other unit ?
How could I change this batch file (Windows XP) to be able to recognize
what is the actual path of the folder that containes these three files ?

Thanks in advance,

Zlatko






----------------------------------------------------------------------------------------------
See our award-winning line of tape and disk-based
backup & recovery solutions at http://www.overlandstorage.com
----------------------------------------------------------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
Reply | Threaded
Open this post in threaded view
|

Re: Instalation batch file

Zlatko Matic
In reply to this post by Glenn Davy
Thank you for answer. It seems that %HOMEDRIVE% is just enough to solve this
problem.
Thanks.

----- Original Message -----
From: "Glenn Davy" <[hidden email]>
To: "Zlatko Matić" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 04, 2005 12:15 AM
Subject: Re: [GENERAL] Instalation batch file


On Wed, 2005-08-03 at 23:29 +0200, Zlatko Matić wrote:

> Hello.
>
> I would like to install database schema on a server using  files with
> dumped schema and globals (produced by dumpall), that are placed on
> CD. The installation script (batch file) that restores these two files
> is also placed on the same CD, (let's say E:) in the same folder.
>
> cd C:\Program Files\PostgreSQL\8.0\bin
> psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
> psql -f E:\MYBASE_SHEMA.dumpall template1 -U zmatic
> vacuumdb -d MYBASE -U zmatic
>
> But, what if CD is F: or some other unit ?
> How could I change this batch file (Windows XP) to be able to
> recognize what is the actual path of the folder that containes these
> three files ?

Im not sure how to determine the path to the media (esp if more than one
cd/dvd), but you could take a couple of different approaches:
1)that is to run the script from the cd drive and build the path to pg's
bin with %HOMEDRIVE%. Type 'SET' to see what other shell variables
there are
2) Run the script from anywhere and take %1 type command line paramaters
to ask location of either bin and/or cd/dvd

Been years since I've had the misfortune to have to use windows shell
scipts, but there are prob many other approachs - best to do a little
research into windows shell scripting and determine best for your
scenario.

Glenn
>
> Thanks in advance,
>
> Zlatko


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org 


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match