I have a postgresql db with about 85+ tables. I make backups regularly using pg_dump
(via php-pgadmin) in copy mode and the size of the backup file is almost 10-12 MB. Now the problem I am facing is that whenever I try to restore the database, foreign key constraint problem occur. The scenario is as follows:
There are two tables: 1) users
and 2) zones
. I have stored the id of zone in users
table to identify the user's zone and have set it as foreign key.
When I take the db dump, the entries for table zones
come only after that of table users
. I think it's due to the first letter of table name: u
comes before z
, and therefore when I restore the database, a foreign key constraint problem occurs and the execution stops. The same problem occurs when I try to restore the db structure, it says the table zones
does not exist in the database since the structure of zones
comes after that of users
in the dump file.
Is there any solution for this? Is there any other backup method feasible?