pgsql dump

pgsql dump

Postby 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
accessor
 
Posts: 10
Joined: Fri 29 Jun 2007 10:48

Postby 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()
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44

Postby 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.....
accessor
 
Posts: 10
Joined: Fri 29 Jun 2007 10:48

Postby 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.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL