Magento Disaster Recovery auf MySQL Ebene

Magento Disaster Recovery auf MySQL DatenbankebeneNote: This information can also be found in English on the Magento Wiki!

Einer unserer Magento Kunden wurde unbeabsichtigt mit einer über den Virtualmin Script Installer installierten Magento Installation von Version 1.4.0.1 auf 1.4.1.0 geupgraded, was dazu führte, dass weder der Magento Shop, noch der Magento Adminbereich erreichbar waren.

Wir versuchten daraufhin erfolglos die Datenbank mit einer neu installierten Magento Version 1.4.0.1 zu verbinden und entschlossen uns daraufhin dazu, alle Datenbanktabellen, die mit catalog* und eav* beginnen zu exportieren und nur diese in eine frische Datenbank der Version 1.4.0.1 zu importieren. Sobald man Foreign Key Checks für MySQL deaktiviert hat, ist dies auch weiter kein Problem. Auch das in Magento integrierte Datenbank Backup Tool ergänzt foreign_key_checks = 0 in seinem MySQL Dump, so dass dieses bei einem Restore keine Foreign Key Constraint Fehler hervorrufen kann.

In den folgenden drei Schritten, ist diese Aufgabe sehr schnell zu bewältigen.

  1. Alle catalog* und eav* Tabellen (via phpMyAdmin) aus der alten Datenbank exportieren
  2. Alle catalog* und eav* Tabellen in der neuen Datenbank löschen
  3. Alle in Schritt 1 exportieren Tabellen in die neue Datenbank importieren

Wenn man bei Schritt 1 in phpMyAdmin noch das Häkchen bei –add-drop-table auswählt, kann man sich Schritt 2 eigentlich auch sparen, merke ich gerade.

Für den Fall, dass Sie Schritt 2 ausführen, hier der Einfachheit halber die entsprechenden DROP TABLE Befehle (kann mit regex search/replace in VIM schnell gebastelt werden, war aber eigentlich unnötig wie eben schon erwähnt):

SET foreign_key_checks = 0;
DROP TABLE IF EXISTS catalog_category_anc_categs_index_idx;
DROP TABLE IF EXISTS catalog_category_anc_categs_index_tmp;
DROP TABLE IF EXISTS catalog_category_anc_products_index_idx;
DROP TABLE IF EXISTS catalog_category_anc_products_index_tmp;
DROP TABLE IF EXISTS catalog_category_entity;
DROP TABLE IF EXISTS catalog_category_entity_datetime;
DROP TABLE IF EXISTS catalog_category_entity_decimal;
DROP TABLE IF EXISTS catalog_category_entity_int;
DROP TABLE IF EXISTS catalog_category_entity_text;
DROP TABLE IF EXISTS catalog_category_entity_varchar;
DROP TABLE IF EXISTS catalog_category_product;
DROP TABLE IF EXISTS catalog_category_product_index;
DROP TABLE IF EXISTS catalog_category_product_index_enbl_idx;
DROP TABLE IF EXISTS catalog_category_product_index_enbl_tmp;
DROP TABLE IF EXISTS catalog_category_product_index_idx;
DROP TABLE IF EXISTS catalog_category_product_index_tmp;
DROP TABLE IF EXISTS catalog_compare_item;
DROP TABLE IF EXISTS catalog_eav_attribute;
DROP TABLE IF EXISTS catalog_product_bundle_option;
DROP TABLE IF EXISTS catalog_product_bundle_option_value;
DROP TABLE IF EXISTS catalog_product_bundle_price_index;
DROP TABLE IF EXISTS catalog_product_bundle_selection;
DROP TABLE IF EXISTS catalog_product_bundle_stock_index;
DROP TABLE IF EXISTS catalog_product_enabled_index;
DROP TABLE IF EXISTS catalog_product_entity;
DROP TABLE IF EXISTS catalog_product_entity_datetime;
DROP TABLE IF EXISTS catalog_product_entity_decimal;
DROP TABLE IF EXISTS catalog_product_entity_gallery;
DROP TABLE IF EXISTS catalog_product_entity_int;
DROP TABLE IF EXISTS catalog_product_entity_media_gallery;
DROP TABLE IF EXISTS catalog_product_entity_media_gallery_value;
DROP TABLE IF EXISTS catalog_product_entity_text;
DROP TABLE IF EXISTS catalog_product_entity_tier_price;
DROP TABLE IF EXISTS catalog_product_entity_varchar;
DROP TABLE IF EXISTS catalog_product_index_eav;
DROP TABLE IF EXISTS catalog_product_index_eav_decimal;
DROP TABLE IF EXISTS catalog_product_index_eav_decimal_idx;
DROP TABLE IF EXISTS catalog_product_index_eav_decimal_tmp;
DROP TABLE IF EXISTS catalog_product_index_eav_idx;
DROP TABLE IF EXISTS catalog_product_index_eav_tmp;
DROP TABLE IF EXISTS catalog_product_index_price;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_idx;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_opt_idx;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_opt_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_sel_idx;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_sel_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_bundle_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_cfg_opt_agr_idx;
DROP TABLE IF EXISTS catalog_product_index_price_cfg_opt_agr_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_cfg_opt_idx;
DROP TABLE IF EXISTS catalog_product_index_price_cfg_opt_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_downlod_idx;
DROP TABLE IF EXISTS catalog_product_index_price_downlod_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_final_idx;
DROP TABLE IF EXISTS catalog_product_index_price_final_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_idx;
DROP TABLE IF EXISTS catalog_product_index_price_opt_agr_idx;
DROP TABLE IF EXISTS catalog_product_index_price_opt_agr_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_opt_idx;
DROP TABLE IF EXISTS catalog_product_index_price_opt_tmp;
DROP TABLE IF EXISTS catalog_product_index_price_tmp;
DROP TABLE IF EXISTS catalog_product_index_tier_price;
DROP TABLE IF EXISTS catalog_product_index_website;
DROP TABLE IF EXISTS catalog_product_link;
DROP TABLE IF EXISTS catalog_product_link_attribute;
DROP TABLE IF EXISTS catalog_product_link_attribute_decimal;
DROP TABLE IF EXISTS catalog_product_link_attribute_int;
DROP TABLE IF EXISTS catalog_product_link_attribute_varchar;
DROP TABLE IF EXISTS catalog_product_link_type;
DROP TABLE IF EXISTS catalog_product_option;
DROP TABLE IF EXISTS catalog_product_option_price;
DROP TABLE IF EXISTS catalog_product_option_title;
DROP TABLE IF EXISTS catalog_product_option_type_price;
DROP TABLE IF EXISTS catalog_product_option_type_title;
DROP TABLE IF EXISTS catalog_product_option_type_value;
DROP TABLE IF EXISTS catalog_product_relation;
DROP TABLE IF EXISTS catalog_product_super_attribute;
DROP TABLE IF EXISTS catalog_product_super_attribute_label;
DROP TABLE IF EXISTS catalog_product_super_attribute_pricing;
DROP TABLE IF EXISTS catalog_product_super_link;
DROP TABLE IF EXISTS catalog_product_website;
DROP TABLE IF EXISTS catalogindex_aggregation;
DROP TABLE IF EXISTS catalogindex_aggregation_tag;
DROP TABLE IF EXISTS catalogindex_aggregation_to_tag;
DROP TABLE IF EXISTS catalogindex_eav;
DROP TABLE IF EXISTS catalogindex_minimal_price;
DROP TABLE IF EXISTS catalogindex_price;
DROP TABLE IF EXISTS cataloginventory_stock;
DROP TABLE IF EXISTS cataloginventory_stock_item;
DROP TABLE IF EXISTS cataloginventory_stock_status;
DROP TABLE IF EXISTS cataloginventory_stock_status_idx;
DROP TABLE IF EXISTS cataloginventory_stock_status_tmp;
DROP TABLE IF EXISTS catalogrule;
DROP TABLE IF EXISTS catalogrule_affected_product;
DROP TABLE IF EXISTS catalogrule_group_website;
DROP TABLE IF EXISTS catalogrule_product;
DROP TABLE IF EXISTS catalogrule_product_price;
DROP TABLE IF EXISTS catalogsearch_fulltext;
DROP TABLE IF EXISTS catalogsearch_query;
DROP TABLE IF EXISTS catalogsearch_result;
DROP TABLE IF EXISTS eav_attribute;
DROP TABLE IF EXISTS eav_attribute_group;
DROP TABLE IF EXISTS eav_attribute_label;
DROP TABLE IF EXISTS eav_attribute_option;
DROP TABLE IF EXISTS eav_attribute_option_value;
DROP TABLE IF EXISTS eav_attribute_set;
DROP TABLE IF EXISTS eav_entity;
DROP TABLE IF EXISTS eav_entity_attribute;
DROP TABLE IF EXISTS eav_entity_datetime;
DROP TABLE IF EXISTS eav_entity_decimal;
DROP TABLE IF EXISTS eav_entity_int;
DROP TABLE IF EXISTS eav_entity_store;
DROP TABLE IF EXISTS eav_entity_text;
DROP TABLE IF EXISTS eav_entity_type;
DROP TABLE IF EXISTS eav_entity_varchar;
DROP TABLE IF EXISTS eav_form_element;
DROP TABLE IF EXISTS eav_form_fieldset;
DROP TABLE IF EXISTS eav_form_fieldset_label;
DROP TABLE IF EXISTS eav_form_type;
DROP TABLE IF EXISTS eav_form_type_entity;

5 Kommentare zu «Magento Disaster Recovery auf MySQL Ebene»

  1. Pingback: Twitted by therouv

  2. Hello,

    I don’t know if you speak english but I hope you can help me. I had magento 1.4 before and now I want to restore it. I have the magento folder untouched and a sql export of the database it was using at the time.

    I tried to import the tables into a new database, copy the magento folder back on the server but it doesn’t work. The local.xml file is properly configured with the database login parameters.

    The error I get when I try to access it via browser starts with «PDOException Object» and then is a lot of code about some sales_coupon tables. The page keeps on refreshing itself and nothing works.

    I know I have an error somewhere when importing the sql file but almost all of the tables are intact and as before.

    Maybe you know a way to import just the media folder and the products into a new freshly installed magento 1.7?

    Thanks very much!

    Best Regards,
    Robert

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert