I’m unable to use the pgSqlDump routine to create a file that I can then use to import back into the database. The issue is not with the restore routine (using the PgSqlScript command) as I’m able to call pg_dump.exe directly and create a backup file that works great when I go to import it back in. The issue is in the file that gets created using PgSqlDump. My guess is that I’m not doing something right so I will try and be as detailed as possible.
When I call Pg_Dump.exe directly, I use the following command line:
Code: Select all
System.Diagnostics.Process.Start(strPGDumpCommand, strParams)
Code: Select all
strPgDumpCommand = "C:\Program Files (x86)\PostgreSQL\9.0\bin\pg_dump.exe "
strParameters = "--file="c:\users\public\documents\DD3\Backup\DD3_000_000_20111020_070742.pg" --username="postgres" --no-password --disable-dollar-quoting --format=plain --inserts --column-inserts "dd3_000""
I then use the following code to import the backup file. This replaces whatever currently exists in the database:
Code: Select all
Dim strStreamRestore As New StreamReader(gclsSession.App_BackupFolder & "\" & mstrBackupFile)
conn = gclsSession.GetDataConnection(True, True)
sqlText = "DROP DATABASE """ & gclsSession.pg_DatabaseName & """;"
pgCommand = conn.CreateCommand()
pgCommand.CommandText = sqlText
pgCommand.ExecuteScalar()
conn.Close()
sqlText = "CREATE DATABASE """ & gclsSession.pg_DatabaseName & """"
sqlText = sqlText & " With OWNER = postgres"
sqlText = sqlText & " ENCODING = 'UTF8'"
sqlText = sqlText & " TABLESPACE = pg_default"
sqlText = sqlText & " LC_COLLATE = 'English_United States.1252'"
sqlText = sqlText & " LC_CTYPE = 'English_United States.1252'"
sqlText = sqlText & " CONNECTION LIMIT = -1;"
conn.Open()
pgCommand = conn.CreateCommand()
pgCommand.CommandText = sqlText
pgCommand.ExecuteScalar()
conn.Close()
gclsSession.CloseDataConnection()
conn = gclsSession.GetDataConnection(True, False)
sqlText = strStreamRestore.ReadToEnd()
strStreamRestore.Close()
pgScript = New PgSqlScript(sqlText, conn)
pgScript.Execute()
conn.Close()
So instead of calling Pg_Dump.exe directly I want to use PgSqlDump to create the same file.
So here is the code I’m using:
Code: Select all
Dim pgDump As PgSqlDump = New PgSqlDump
pgDump.Connection = gclsSession.GetDataConnection()
pgDump.ObjectTypes = PgSqlDumpObjects.All - PgSqlDumpObjects.Languages
pgDump.IncludeDrop = False
pgDump.IncludeBlob = True
pgDump.QuoteIdentifier = False
pgDump.Backup()
Dim stream As StreamWriter = New StreamWriter(gclsSession.App_BackupFolder & "\" & strFileName)
stream.WriteLine(pgDump.DumpText)
stream.Close()
stream.Dispose()
stream = Nothing
So I’m kind of at a loss as to how to resolve this. Any help would be appreciated. Let me know if I can provide any other information.
Regards,