Bug #12682 Restore fails with can't find...
Submitted: 19 Aug 2005 18:07 Modified: 19 Sep 2008 12:33
Reporter: Mr Wakazula Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Administrator Severity:S4 (Feature request)
Version:1.1.1 OS:Windows (Windows XP (SP2))
Assigned to: CPU Architecture:Any

[19 Aug 2005 18:07] Mr Wakazula
Description:
Typically, when restoring a schema that has been backed up using the
"complete backup" option, errors will be thrown.  "Can't find..."

The problem is due to tables/views referring (either explicitly or via foreign keys) to other tables/views which have not been restored yet. 

How to repeat:
(1) create a schema
(2) populate with tables (`table_one`, `table_two`)
(3) create a view (`a_view`) where `table_one` joins `table_two`
(4) create a FK that refers from `table_one.id` (FK) to `table_two.id` (PK)
(5) backup the schema with the following option selected "complete backup"
(6) delete the schema
(7) restore the schema from backup

restore will fail because it will create a view that refers to a non-existant table

Suggested fix:
Is it possible to have the backup engine perform an initial pass to determine which tables or views should be backed up first?  

A logical BACKUP could look like:
1) backup tables
1a) backup primary tables
1b) backup secondary tables
2) backup views

OR

A logical RESTORE could look like:
1) disable all keys
2) restore tables
3) restore views

The second method would probably avoid the situation where two tables reference each other.
4) enable FKs
[19 Sep 2008 12:33] Susanne Ebrecht
This is a duplicate of bug #6455