By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,178 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,178 IT Pros & Developers. It's quick & easy.

Scripting a new db server setup

P: n/a
A E
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

Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
> 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/view...ver/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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2

P: n/a
A E <co*******@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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #3

P: n/a
A E
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 <do**@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
Nov 12 '05 #4

P: n/a
> 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, bp*****@crimelabs.net pgp:crimelabs.net/bpalmer.pgp5

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

Nov 12 '05 #5

P: n/a
> 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
sc********@killerbytes.com
http://www.killerbytes.com/
(303) 665-7007 voice
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #6

P: n/a
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"

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.