PgSqlDump restore issue

PgSqlDump restore issue

Postby bbmu2000 » Tue 30 Nov 2010 00:41

Hey,

I have a database which contains following tables: user, accessory,company, domain and so on.

I used following code to backup this database, it works fine.

PgSqlConnection conn = new PgSqlConnection( connectionStringBuilder.ConnectionString )
conn.Open();
PgSqlDump pgSqlDump = new PgSqlDump();
pgSqlDump.Connection = conn;
pgSqlDump.Backup( @"c:\backup.dmp" );
conn.Close();

I used following code to restore the database.

PgSqlConnection conn = new PgSqlConnection( connectionStringBuilder.ConnectionString )
conn.Open();
PgSqlDump pgSqlDump = new PgSqlDump();
pgSqlDump.Connection = conn;
pgSqlDump.Restore( @"c:\backup.dmp" );
conn.Close();

The pgSqlDump.Restore throw an exception
"relation "domain" already exists"

Any ideas about this? Thanks.
bbmu2000
 
Posts: 3
Joined: Tue 30 Nov 2010 00:21

Postby StanislavK » Tue 30 Nov 2010 18:04

Apparently, this problem occurs when creating tables, as the drop statements are not included into the backup script by default. If you need to restore the whole database (including the schema), you can add the drop statements to the script by setting the IncludeDrop property of the PgSqlDump object to true before performing backup. If you need to restore data only and leave the schema unchanged, please set the Mode property to Devart.Common.DumpMode.Data.

For more information about the PgSqlDump component, please refer to our documentation:
http://www.devart.com/dotconnect/postgresql/docs/Devart.Data.PostgreSql~Devart.Data.PostgreSql.PgSqlDump.html

Feel free to contact us if anything is unclear.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby bbmu2000 » Tue 30 Nov 2010 20:28

The problem is solved. Thanks for your help!
bbmu2000
 
Posts: 3
Joined: Tue 30 Nov 2010 00:21


Return to dotConnect for PostgreSQL