Thread: Scripting a new db server setup

Scripting a new db server setup

From
A E
Date:
Hi,
 
Was wondering if there are ways to completely script a new postgresql installation. I need to be able to create the db, users, and db elements from one command so that I can included it in a setup routine.
 
Alex

Re: Scripting a new db server setup

From
Karsten Hilbert
Date:
> Was wondering if there are ways to completely script a new
> postgresql installation. I need to be able to create the db,
> users, and db elements from one command so that I can included
> it in a setup routine.

http://savannah.gnu.org/cgi-bin/viewcvs/gnumed/gnumed/gnumed/server/bootstrap/

is one possibility you might consider.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

Re: Scripting a new db server setup

From
Doug McNaught
Date:
A E <cooljoint@yahoo.com> writes:

>    Hi,
>
>
>
>    Was wondering if there are ways to completely script a new postgresql
>    installation. I need to be able to create the db, users, and db
>    elements from one command so that I can included it in a setup
>    routine.

Absolutely--write SQL scripts that do the work and feed them to 'psql'
in a shell script.

-Doug

Re: Scripting a new db server setup

From
A E
Date:
Thanks Doug! I got some weird errors though when trying to run a command to create db, create user, create elements from the pgAdmin sql editor. I was trying to test and in a nutshell it not allow me to create the db in the same script as everything else, because I seperated the parts and it worked fine.
 
Thanks Karsten, but I was unsure of what I was looking at.
 
Alex

Doug McNaught <doug@mcnaught.org> wrote:
A E writes:

> Hi,
>
>
>
> Was wondering if there are ways to completely script a new postgresql
> installation. I need to be able to create the db, users, and db
> elements from one command so that I can included it in a setup
> routine.

Absolutely--write SQL scripts that do the work and feed them to 'psql'
in a shell script.

-Doug

Re: Scripting a new db server setup

From
bpalmer
Date:
> Was wondering if there are ways to completely script a new postgresql installation. I need to be able to create the
db,users, and db elements from one command so that I can included it in a setup routine. 

That's rather easy.

A shell script can do roughly the following:

- initdb somewhere
- start PG
- run 'psql template1 < myload.sql'

The myload.sql would connect to template1,  do a "createdb newdbname" and
start creating tables,  etc.

Almost the same concept as doing a restore from a pg_dumpall.

- Brandon

----------------------------------------------------------------------------
 c: 917-697-8665                                            h: 201-435-6226
 b. palmer,  bpalmer@crimelabs.net           pgp:crimelabs.net/bpalmer.pgp5

Re: Scripting a new db server setup

From
Scott Ribe
Date:
> Thanks Doug! I got some weird errors though when trying to run a command to
> create db, create user, create elements from the pgAdmin sql editor. I was
> trying to test and in a nutshell it not allow me to create the db in the same
> script as everything else, because I seperated the parts and it worked fine.

I think it's likely that at some point you wound up connected to wrong db
and need a connect command somewhere in your script. For instance, you
connect to template1 to start because your db doesn't exist yet, now
creating your db doesn't connect you to it. But when you split the script,
you explicitly connect to your db for the second script.


--
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 665-7007 voice


Re: Scripting a new db server setup

From
"Roderick A. Anderson"
Date:
On Sun, 4 Jan 2004, A E wrote:

> Hi,
>  Was wondering if there are ways to completely script a new postgresql
> installation. I need to be able to create the db, users, and db
> elements from one command so that I can included it in a setup
> routine.

How about pgbash.  Is it still being supported?  The page
(http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html) I looked at shows
the last version as 7.3 (Feb 2003) which coincides with Pg V 7.3.

Funny this should come up now as I am looking for a way to do the same
thing.  Serendipity eh?


Rod
--
    "Open Source Software - You usually get more than you pay for..."
     "Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"