Thread:
Hi All: I am thinking about using PostgreSql as the back end of Windows application. I plan to install postgreSql in silent mode as part of my application's setup program. I have couple of questions about this: 1. How do I programmatically call backup (pg_dump) and vacuum? I am using .NET provider as the interface to the postgreSql. I didn't see any provision in the .Net provider to invoke these commands. Does postgresql support SQL's "BACKUP" and "RESTORE" commands? 2. As part of installation I would like to create and populate a new database. What is the easiest way to this? What I am thinking of doing is to install psql client program and using it to create database. Is there any way I don't have to install psql on every client's machine? Thanks in advance for your responses. Regards, Karim Mardhani ZeeCore Consulting
On Jan 19, 2005, at 7:10 AM, Karim Mardhani wrote: > 1. How do I programmatically call backup (pg_dump) and vacuum? I am > using .NET provider as the interface to the postgreSql. I didn't see > any provision in the .Net provider to invoke these commands. Does > postgresql support SQL's "BACKUP" and "RESTORE" commands? I'm not familiar with .net, but I would guess there is a way to execute command line programs? So you would have to know the location of the PostgreSQL bin directory (which should be in the registry from the install) and then call the pg_dump.exe binary. Vacuum is a normal SQL command which you could call using psql and the -c option. > > 2. As part of installation I would like to create and populate a new > database. What is the easiest way to this? What I am thinking of > doing > is to install psql client program and using it to create database. Is > there any way I don't have to install psql on every client's machine? > Same approach as above using initdb.exe and createdb.exe utilities. Or psql would work as long as you already have a cluster setup. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL
On Jan 21, 2005, at 2:19 AM, John DeSoi wrote: > > On Jan 19, 2005, at 7:10 AM, Karim Mardhani wrote: > >> 1. How do I programmatically call backup (pg_dump) and vacuum? I >> am >> using .NET provider as the interface to the postgreSql. I didn't see >> any provision in the .Net provider to invoke these commands. Does >> postgresql support SQL's "BACKUP" and "RESTORE" commands? > > I'm not familiar with .net, but I would guess there is a way to > execute command line programs? So you would have to know the location > of the PostgreSQL bin directory (which should be in the registry from > the install) and then call the pg_dump.exe binary. Vacuum is a normal > SQL command which you could call using psql and the -c option. > >> >> 2. As part of installation I would like to create and populate a >> new >> database. What is the easiest way to this? What I am thinking of >> doing >> is to install psql client program and using it to create database. Is >> there any way I don't have to install psql on every client's machine? >> > > Same approach as above using initdb.exe and createdb.exe utilities. Or > psql would work as long as you already have a cluster setup. I would add that pgadminIII is a very nice way to interact with the database and probably deserves a look. You could install that on the other machines, rather than psql. Sean
> 1. How do I programmatically call backup (pg_dump) and vacuum? I am > using .NET provider as the interface to the postgreSql. I didn't see > any provision in the .Net provider to invoke these commands. Does > postgresql support SQL's "BACKUP" and "RESTORE" commands? Why not use the AT scheduler to just to a dump for you ? If you do this every night then that should solve most backup related problems. I think that VACCUM can be from psql. Check the docs for that one, it should be available. > > 2. As part of installation I would like to create and populate a new > database. What is the easiest way to this? What I am thinking of doing > is to install psql client program and using it to create database. Is > there any way I don't have to install psql on every client's machine? Fastest way is to use the createdb command, so find that one and see if you can execute that on the database server, this should allow you to create the database. Someone mentioned PGAdmin III that is a good tool, but make sure that you can use the command line utilities first. Cheers, Aly. -- Aly Dharshi aly.dharshi@telus.net "A good speech is like a good dress that's short enough to be interesting and long enough to cover the subject"