Egon.Schiller
Egon.Schiller

Reputation: 63

VB Script PostgreSQL pg_dump

I'm writing a backup script in VBScript for a PostgreSQL 9.1 database on a Window 7.

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run postgresqlPath & "pg_dump.exe " & ServerId & " > " &  backupFolder & "Database.dump.out"
Wscript.Sleep 500
 objShell.SendKeys "Password~"

This script seems to run twice and returns no file in the destination folder.

To exclude errors in the path I had tried the command into the command-line tool, there everything worked fine as expected.

Any hints are appreciated

Upvotes: 2

Views: 1471

Answers (1)

Oberdan
Oberdan

Reputation: 321

You can also use a DOS script

pg_dump --host 192.168.0.1 --port 5432 --username "postgres" --role "postgres" --no-password --format plain --encoding UTF8 --inserts --verbose --file "C:\backup\mydatabase%ldt%.sql" "mydatabase"

Upvotes: 2

Related Questions