Friday, November 7, 2014

Manual Upgrade using fresh install and original database

By Brent W. Peterson

Agency Coach and Evangelist at WagentoCommerce

This guideline will insure you have a stable version of your site installed with the newest version of Magento software. This upgrade procedure does not rely on Connect or FTP. Peterson recommends using Magerun to perform the upgrade of the database and the subsequent indexing that will be required. You can get more information here Magerun

Peterson also recommends this procedure for upgrading from Magento CE to Magento EE.

Overview

This should be a complete list of items for upgrading the production database, rolling out the new codebase, and transferring DNS resolution to the new Magento instance.

Pre-install

Your pre-install prep-work will save you time and money after you have done you upgrade. The more methodical you are in your preparation, the smother your upgrade will go.

Turn off Indexing for EE

Make sure you server is configured properly!

  1. Set your DNS ttl to 300 or less. Do this now or you make forget later!
  2. Clear and turn your cache off

If you are going to use the browser to upgrade do the following:

Make sure Apache Timeout is set to 18000

Set max_execution time on PHP to 0

Identify and list modules to go to upgraded version

  1. Diff Core of original version to clean core of same version
  2. You may not need all you modules brought over and some modules will not be compatible in a newer version. Each one must be checked and tested.
  3. Make sure to check your Local and Community Folder.
  4. If you have a local/Mage folder you will need to check if the code is compatible with the version you are upgrading to.

Identify theme components to transfer

  1. Diff theme with base or default version of original theme
  2. Make sure all your theme files are in the correct folders and more importantly make sure you theme is compatible with the version you are upgrading to. It is best to test your upgrade on the default theme, then slowing add in just the theme files you need for your theme. There are layout files that are specific to the newer versions of Magento and it is important that these files are used for you install. A good example is checkout.xml.

Identify external components that need to function with new version, review on Magento integration options (i.e. does it make sense to make the external app a Magento app or leave it as an external app)

  1. This also includes API’s that are running and/or loading Mage out side of Magento. Sometimes it make sense to move these external apps to proper Magento extensions.

    Check that all your Magento indexes are up to date

    Dump old database and restore in new database
  2. mysqldump -u user -p ‘password’ -h host olddatabase > yourdump.sql
  3. mysql -u user -p ‘password’ -h host newdatabase < yourdump.sql

    For each upgrade attempt you will need to drop you new database and recreate it, you can not simply restore over an already upgraded database.

Process

Database Upgrade

  1. Export Live database to an SQL dump file (db-YY-MM-DD-pre.sql)
  2. Transfer db-YY-MM-DD-pre.sql to the dedicated database upgrade server and imported into the local MySQL instance
  3. Navigate to your sites main page to instantiate the upgrade process. For more advanced users: I am now recommending you use [[https://github.com/netz98/n98-magerun]] as magerun sys:setup:run
  4. Let process run until finished
  5. Re-index site (magerun index:reindex:all)
  6. Export Upgraded database to an SQL dump file (db-YY-MM-DD-post.sql)
  7. Transfer db-YY-MM-DD-post.sql to the production machine and import into the local MySQL instance

Post Upgrade

  1. Correct Store Issues (Update so admin can login!)
  2. Execute necessary scripts (Many upgrades require database alterations, these should be documented and scripted)
  3. Enter Admin panel and set the following configuration values:
  4. Themes and packages set to default
  5. Refresh cache and indexes

Launch

  1. Switch the Apache vhost references to point to the new instance, disable the old instance
  2. Restart Apache
  3. Site is now live

Other considerations

There are some URL scripts that need to be run when upgrading to 1.13. Please see the documentation here [[http://www.magentocommerce.com/knowledge-base/entry/ce18-and-ee113-upgrading]]

Please feel free to comment and send feed back on this document.

brent@wagento.com

Brent W. Peterson

Peterson’s philosophy on doing upgrades is as William Shakespeare said “Listen to many, speak to a few.”

Tuesday, October 28, 2014

Reviving the old site

As you can see from the post history, it has been a number of years since I posted to this site.

My newest cause is the Liver Foundation

Did you know:
<ul><li>Liver disease is one of the top 10 causes of death in the U.S. Thousands of individuals wait every year for a life-saving liver transplant.
</li><li>There are 5.4 million people in the United States living with chronic Hepatitis B or C.
</li><li>25% of Americans are being diagnosed with fatty liver disease, and 10% are children.
</li></ul>

I am asking for 1 mile for each mile I run in the Boston Marathon. ($26.20)

 http://go.liverfoundation.org/goto/brentwpeterson

Monday, August 20, 2012

Pre-dump database reduction script

Big databases are always a problem and it is handy to clean up your database before you are going to do a db dump. This is most handy when you have to move the dump from one server to another. The syntax for you file will be something like this
truncate dataflow_batch_export;
truncate dataflow_batch_import;
truncate log_customer;
truncate log_quote;
truncate log_summary;
truncate log_summary_type;
truncate log_url;
truncate log_url_info;
truncate log_visitor;
truncate log_visitor_info;
truncate log_visitor_online; 
truncate report_viewed_product_index;
truncate report_compared_product_index;
truncate report_event;
truncate report_viewed_product_aggregated_daily;
truncate report_viewed_product_aggregated_monthly;
truncate report_viewed_product_aggregated_yearly;
truncate sendfriend_log;
Then you want to save this as a sql file. (cleandb.sql) Then you can run it against your current database (After you make a backup) like this: First I would take a current backup of your database like this
mysqldump -p'password' -u user -h hostaddress databasename | gzip > backup.sql.gz
Then run the clean script
mysql -p'password' -u user -h hostaddress databasename < cleandb.sql

Wednesday, July 11, 2012

Delete all Magento Products

Delete all your products in Magento

If you don't know what you are doing don't do this. It will completely ruin your site. You will have no products left. Always make a backup! This is tested on 1.6 + Vern has pointed out I need to remove products and categories, I have posted his update
SET FOREIGN_KEY_CHECKS = 0;
        TRUNCATE TABLE `core_url_rewrite`;
        TRUNCATE TABLE `catalog_product_relation`;
        TRUNCATE TABLE `catalog_category_entity`;
        TRUNCATE TABLE `catalog_category_entity_datetime`;
        TRUNCATE TABLE `catalog_category_entity_decimal`;
        TRUNCATE TABLE `catalog_category_entity_int`;
        TRUNCATE TABLE `catalog_category_entity_text`;
        TRUNCATE TABLE `catalog_category_entity_varchar`;
        TRUNCATE TABLE `catalog_category_product`;
        TRUNCATE TABLE `catalog_category_product_index`;

        INSERT  INTO `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) VALUES (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
        INSERT  INTO `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,34,0,2,1),(2,3,34,1,2,1);
        INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES
            (1,3,33,0,1,'Root Catalog'),
            (2,3,35,0,1,'root-catalog'),
            (3,3,33,0,2,'Default Category'),
            (4,3,41,0,2,'PRODUCTS'),
            (5,3,35,0,2,'default-category');
        TRUNCATE TABLE `catalog_product_bundle_option`;
        TRUNCATE TABLE `catalog_product_bundle_option_value`;
        TRUNCATE TABLE `catalog_product_bundle_selection`;
        TRUNCATE TABLE `catalog_product_entity_datetime`;
        TRUNCATE TABLE `catalog_product_entity_decimal`;
        TRUNCATE TABLE `catalog_product_entity_gallery`;
        TRUNCATE TABLE `catalog_product_entity_int`;
        TRUNCATE TABLE `catalog_product_entity_media_gallery`;
        TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
        TRUNCATE TABLE `catalog_product_entity_text`;
        TRUNCATE TABLE `catalog_product_entity_tier_price`;
        TRUNCATE TABLE `catalog_product_entity_varchar`;
        TRUNCATE TABLE `catalog_product_link`;
        TRUNCATE TABLE `catalog_product_link_attribute`;
        TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
        TRUNCATE TABLE `catalog_product_link_attribute_int`;
        TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
        TRUNCATE TABLE `catalog_product_link_type`;
        TRUNCATE TABLE `catalog_product_option`;
        TRUNCATE TABLE `catalog_product_option_price`;
        TRUNCATE TABLE `catalog_product_option_title`;
        TRUNCATE TABLE `catalog_product_option_type_price`;
        TRUNCATE TABLE `catalog_product_option_type_title`;
        TRUNCATE TABLE `catalog_product_option_type_value`;
        TRUNCATE TABLE `catalog_product_super_attribute_label`;
        TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
        TRUNCATE TABLE `catalog_product_super_attribute`;
        TRUNCATE TABLE `catalog_product_super_link`;
        TRUNCATE TABLE `catalog_product_enabled_index`;
        TRUNCATE TABLE `catalog_product_website`;
        TRUNCATE TABLE `catalog_category_product_index`;
        TRUNCATE TABLE `catalog_category_product`;
        TRUNCATE TABLE `cataloginventory_stock_item`;
        TRUNCATE TABLE `cataloginventory_stock_status`;
        TRUNCATE TABLE `cataloginventory_stock`;
        TRUNCATE TABLE `catalog_compare_item`;
        TRUNCATE TABLE `adminnotification_inbox`;
        TRUNCATE TABLE `index_event`;
        TRUNCATE TABLE `index_process_event`;
        TRUNCATE TABLE `log_url_info`;
        TRUNCATE TABLE `log_url`;
        TRUNCATE TABLE `log_visitor`;
        TRUNCATE TABLE `log_visitor_info`;
        TRUNCATE TABLE `report_viewed_product_index`;
        TRUNCATE TABLE `report_event`;
        DELETE FROM `eav_attribute_option` WHERE attribute_id = 70;
        DELETE `eav_attribute_option_value`.* FROM `eav_attribute_option_value` LEFT JOIN `eav_attribute_option` USING (`option_id`) WHERE `eav_attribute_option`.`option_id` IS NULL;
        INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
        INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
        INSERT  INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
        TRUNCATE TABLE `catalog_product_entity`;
        SET FOREIGN_KEY_CHECKS = 1;

SSH Upgrade for Magento

Just a quick way to upgrade you site
find . -type f -exec chmod 777 {} \;
find . -type d -exec chmod 777 {} \;
rm -rf var/cache/* var/session/*
chmod 550 ./mage
./mage mage-setup .
./mage config-set preferred_state stable
./mage list-installed
./mage list-upgrades
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
php shell/indexer.php reindexall
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

Wednesday, October 26, 2011

Installing Magento Via SSH

Installing Magento With The Full Download

Installing Into The Website Document Root

I took this content from the Magento WIKI page, since they have removed the Search feature for the Magento WIKI's I figured it would be easier to find this way for myself and others! Since this Post will soon become outdated, I must tell you to change the version number for your download. i.e. if you want version 1.5.1 you will put magento-1.5.1.0.tar.gz When version 1.7 comes out you will need magento-1.7.0.0
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-1.6.1.0.tar.gz
tar -zxvf magento-1.6.1.0.tar.gz
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc
rm -rf magento/ magento-1.6.1.0.tar.gz

Install Magento using the downloader

wget http://www.magentocommerce.com/downloads/assets/1.5.0.0/magento-downloader-1.5.0.0.tar.gz
tar -zxvf magento-downloader-1.5.0.0.tar.gz
rm -rf magento-downloader-1.5.0.0.tar.gz

Install into a Subdirectory

For this install you only need to replace SUBDIRECTORY below (two times) with the name of the subdirectory that you want Magento installed in.
mkdir SUBDIRECTORY
cd SUBDIRECTORY
wget http://www.magentocommerce.com/downloads/assets/1.5.0.0/magento-downloader-1.5.0.0.tar.gz
tar -zxvf magento-downloader-1.5.0.0.tar.gz
rm -rf magento-downloader-1.5.0.0.tar.gz

Installing Magento With The Downloader & Sample Data

Installing into the Root Web Directory

wget http://www.magentocommerce.com/downloads/assets/1.5.0.0/magento-downloader-1.5.0.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
tar -zxvf magento-downloader-1.5.0.0.tar.gz
tar -zxvf magento-sample-data-1.2.0.tar.gz
mv magento-sample-data-1.2.0/media/* magento/media/
mv magento-sample-data-1.2.0/magento_sample_data_for_1.2.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod -R o+w media
mysql -h DBHOST -u DBUSER -p'DBPASS' DBNAME < data.sql
./mage mage-setup .
./mage install magento-core/Mage_All_Latest-stable
chmod o+w var app/etc
rm -rf magento/ magento-sample-data-1.2.0/
rm -rf magento-downloader-1.5.0.0.tar.gz magento-sample-data-1.2.0.tar.gz data.sql
Please visit the Magento site and post to the forum if you have any questions or problem. Click to visit Magento Forums

Monday, October 3, 2011

How to find the Magento version - Quick and Easy

Many Magento store leave the release notes in the root of their website. This is the fastest way to find out what version the site is running

http://www.domain.com/RELEASE_NOTES.txt

Of course if you remove the file or change the permissions you will not find it.