Page 1 of 1

PgSqlDump restore issue

Posted: Tue 30 Nov 2010 00:41
by bbmu2000
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.

Posted: Tue 30 Nov 2010 18:04
by StanislavK
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/postgr ... lDump.html

Feel free to contact us if anything is unclear.

Posted: Tue 30 Nov 2010 20:28
by bbmu2000
The problem is solved. Thanks for your help!