0
votes

I have some problem for backup and restore database using python for OpenERP. I would like to backup sale_order table and related tables for this. But... I don't know how to restore that backup file because there have some related keys (foreign key) vice visa..

e.g. I have backup file for sale_order that related tables like this:

insert into sale_order ....
insert into sale_order_line ...

that time, I have error for sale_order_line because sale_order_line have foreign key for procurement_order's id ... so I changed

insert into sale_order...
insert into procurement_order...
insert into sale_order_line...

but ... I've an error at procurement_order for foreign key for stock_move's id... so I changed again...

insert into sale_order...
insert into stock_move...
insert into procurement_order...
insert into sale_order_line...

but... it's still not OK :( because stock_move have foreign key of sale_order_line'id... I don't know how to do...

That's why... What is the best solution for this backup and restore for that case? If you have any idea, please give me. Thanks.

1
Why did you decide not to use pg_backup?Richard Huxton
Because the customer want to backup & restore data from the OpenERP UI. They'd the some shop that didn't get internet network so that they want to upload sale/pos data of this shop to the main database.sharipha
So it's not backup + restore, it's export + import.Richard Huxton
yeah! It's export + import. How can I do for that case. If you don't mind, please explain me. Thanks.sharipha

1 Answers

0
votes

Without providing schemas for the tables with their foreign keys it's difficult to provide accurate help.

It is possible to generate data that defies a simple batch insert. You can leave a FK null and set it after dependencies are added.

So - you probably want to read up about deferring constraints and disabling foreign keys. Start here for a quick overview and work out from there.

Oh - and are you sure you won't have any problems with overlapping primary keys from this setup?