Upgrading your Magento Store: a Practical Guide

Upgrading your Magento Store: a Practical Guide

Andy Holland

Making sure that the Magento platform is up to date is essential for your store. It ensures that your site is secure and makes sure that you have all of the latest features. But how do you go about updating to the latest version? Allow Andy and our Magento Development team to explain all:

For this blog post we’ll say we’re installed at /home/magtest/public_html, that the database is on localhost and is called magtest_magento to help you to understand what’s going on. Make sure that you replace these with the relevant info for your store as you follow along.

  1. Backup your Store

If you do any kind of update, whether to the platform or to your store, you should always make sure that you have a backed up copy of your store. This protects you in case of any problems, allowing you to rollback where necessary.

You can backup your store using these two commands.

tar -czf ~/magento-files.tar.gz -C /home/magtest public_html

mysqldump –add-drop-table -h localhost -u magtest -p magtest_magento | gzip > ~/magento-db.sql.gz

If the worst happens and anything does go awry, you can simply roll back.

cd /home/magtest

mv public_html public_html-BAK

tar -xzf ~/magento-files.tar.gz

gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magtest -p magtest_magento

  1. System Requirements Check

Make sure that your server meets the minimum requirements for the version of Magento that you are upgrading to.

  1. Create a Sandbox

Don’t try upgrading anything until you have tested on a sandbox.

You don’t want to upgrade your store to find out that there is an issue, losing a day’s revenue. Instead, create a sandbox which you can upgrade first. We have created an empty database, magtest_staging, to do this.

cd /home/magtest

mkdir public_html/staging

tar -xzf ~/magento-files.tar.gz –strip-components=1 -C public_html/staging

gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magtest -p magtest_staging

Set up the sandbox by following these instructions:

  • Edit the database connection settings in public_html/staging/app/etc/local.xml
  • Go to magtest_staging database, find the core_config_data table and change the URL of the website. If the old URL was http://magtest.local/, then the new one will be http://magtest.local/staging/
  • If your Magento store uses Apache rewrites, then add RewriteBase /staging/ inpublic_html/staging/.htaccess
  • Turn compilation off at System > Tools > Compilation
  • Disable cache at System > Cache Management
  1. Upgrade the Sandbox

Run these commands next in the console.

cd /home/magtest/public_html/staging

chmod +x pear

./pear mage-setup

./pear upgrade -f magento-core/Mage_All_Latest-stable

chmod +x mage

./mage config-set preferred_state stable

./mage upgrade-all –force


If the earlier command fails, try this one:

./mage install http://connect20.magentocommerce.com/community Mage_All_Latest –force


Clear the cache with:

cd /home/magtest/public_html/staging

rm -fr var/cache var/session var/full_page_cache


To finish the upgrade, open the home page allowing Magento to update the database:

cd /home/magtest/public_html/staging

php -f index.php

  1. Testing

Thoroughly test how well your site is working. Check out the Magento logs at home/magtest/public_html/staging/var/log and the web server logs at at/var/log/httpd/var/log/apache2 or /var/log/nginx depending on the server you use. Keep an eye out for errors. Remember also that extensions may suffer from errors or conflict.

  1. Update Main Site

If everything looks hunky-dory, update your main site. Switch your site to maintenance mode and make sure you disable cron.

touch /home/magtest/public_html/maintenance.flag

crontab -u magtest -e


Save yourself a backup copy:

cd /home/magtest

tar -czf magento-files.tar.gz -C /home/magtest public_html

mysqldump –add-drop-table -h localhost -u magtest -p magtest_magento | gzip > ~/magento-db.sql.gz


Repeat the update procedure, this time on your main store site and not the staging version.

Finally, turn off maintenance mode and re enable cron.

rm /home/magtest/public_html/maintenance.flag

crontab -u magtest –e


There you have it! An updated store.

If you need help with upgrades or any other aspect of your Magento store, get in touch with Elementary Digital today.