pgsql dump

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
accessor
Posts: 10
Joined: Fri 29 Jun 2007 10:48

pgsql dump

Post by accessor » Tue 13 Jan 2009 15:44

hello,

When i try to make a backup using :
QBcon.Open()
Dim Dump As PgSqlDump = New PgSqlDump
'Dim Dump_mode As DumpMode = New DumpMode = DumpMode.All
Dump.Connection = QBcon
'Dump.IncludeDrop = True
Dump.IncludeBlob = True
Dump.Mode = DumpMode.Data
' Dump.Schema = "fysio.store"
Dump.Backup("d:\test.sql")

QBcon.Close()

Its making a file.

then i try to restore using

Dim Dump As PgSqlDump = New PgSqlDump
Dump.DumpText = DMPtext
QBcon.Open()
Dim Pids_restore As PgSqlDump = New PgSqlDump
Pids_restore.Connection = QBcon
'Pids_restore.Mode = DumpMode.All
'Pids_restore.IncludeDrop = True
Pids_restore.IncludeBlob = True
Pids_restore.Restore("d:\test.sql")
QBcon.Close()

i get an error like:

duplicate key value violates unique constraint "pg_ts_cfg_pkey"


Please tell me what i am doing wrong here.

best regards

martijn

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 14 Jan 2009 11:16

You get this error because you are trying to insert data into the table with a primary key where the same values of the primary key column already exist (you have made a dump of the table, but have not cleared it before inserting data with the PgSqlDump.Restore() method).

As an alternative, try the following code where DumpMode.All is used instead of DumpMode.Data:

Code: Select all

        QBcon.Open()
        Dim Dump As PgSqlDump = New PgSqlDump
        Dump.Connection =  QBcon
        Dump.IncludeDrop = True
        Dump.Mode = DumpMode.All //schema + data
        Dump.Tables = "emp;dept"   //the tables from my database
        Dump.Backup("d:\test.sql")
        
        //restoring schema and data from the file
        Dump.Restore("d:\test.sql")
        PgSqlConnection1.Close()

accessor
Posts: 10
Joined: Fri 29 Jun 2007 10:48

Post by accessor » Thu 15 Jan 2009 07:59

Thank you for your reply.
i omitted the .tables property as stated in the help but it seems to give a lot of problems.

anyway another question:

is there a way to tell when the backupprocedure is totally finished?

I like to let my users know when the whole process is finished with the backup and go on with my program and or check the backup.

thank you in advance.....

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 15 Jan 2009 09:11

The PgSqlDump class doesn't have any event that indicates finishing the backup operation. But the Backup() function returns control to the program when the backup operation is finished. So, the line of code next to the Dump.Backup(...) function will be executed only after finishing backup.

Post Reply