How to upgrade Magento version

Table of Content

How to uprgade Magento version
Posted in: Magento 2 Guides

Good day to Amasty blog readers! Today I’m speaking on a topic our team had many requests for: how to update your Magento store correctly?

We have been talking about the importance of upgrading software a lot; it is crucial both for your server software and your Magento new version installation. Regular Magento updates bring you not only the new features but also security fixes, which is highly important for your Magento store’s safety.

Feel free to check the post on Magento security details.

Say, you see that your Magento version needs an upgrade. It’s hard to guess which version you have now, but we hope it’s at least.

Thinking of how to start with Magento migration? Talk to our expert, book a free consultation, or/and hire our developers to migrate your M1 to M2.

1. Prepare for Magento upgrade

To make the process more vivid we installed a shop on Magento with sample data and we are going to upgrade it to, which is the latest stable Magento version as of this writing.

The website is installed into /home/mgtest/public_html, the database is on localhost and is called mgtest_magento. So if you use the instructions from this article, make sure you replace these values with your own ones.

→ Upgrade your Magento 2.3.0 to the latest version

2. Full Magento backup

This rule refers not only to upgrading Magento, but to any serious changes you’re going to apply on your website.

Backup your Magento store!

This is an essential procedure which saves you from unsuccessful updates, site breakdowns, data loss and makes sure the update won’t drive you up the wall.

The simplest variant of Magento backup can be implemented using these two commands:

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

mysqldump --add-drop-table -h localhost -u mgtest -p mgtest_magento | gzip > ~/magento-db.sql.gz

Please feel free to read a detailed article on Magento backup.

In case your Magento version update goes wrong, you can easily roll everything back:

cd /home/mgtest

mv public_html public_html-BAK

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

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

3. Check system requirements

Check if your server suits minimum system requirements of the Magento version you’re upgrading to. You may want to have a look at the PHP version (5.4.x or 5.5.x is needed) and memory_limit value in php.ini in the first place.

Chck out the PHP version requirements for different Magento versions (2.3.0, 2.3.1, 2.3.2, etc) → 

4. Create a sandbox

Never ever update the primary website if you’re not 100% sure everything’s go. If you don’t test the update on a sandbox you won’t know if the website is going to work after the update and how much time the upgrading process will take.

Your store’s upgrade may require up to several hours, and there’s no point in shutting the primary e-shop down for the whole working day just to find out that the upgrade went wrong, the time’s lost and all you have to do is to restore the website from a backup copy. Also, remember that recovering from a backup copy takes more time than backing up itself, so count this time in.

To check if the update is going to run smoothly, let’s make a sandbox which we’re going to upgrade first. We have created an empty mgtest_staging database beforehand.

cd /home/mgtest

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 mgtest -p mgtest_staging

Now it’s time to set the sandbox up:

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

Now the sandbox is ready to be upgraded.

5. Magento sandbox upgrade

Run the following commands in the console:

cd /home/mgtest/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 previous command isn’t working, run this one:

./mage install Mage_All_Latest --force

Clear cache:

cd /home/mgtest/public_html/staging

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

To finish the upgrade magento version open the home page so Magento updates the database. This process can be lengthy, so consider doing it with the following command:

cd /home/mgtest/public_html/staging

php -f index.php

6. Test, test, test

Carefully check how your website is working. Go to Magento logs at /home/mgtest/public_html/staging/var/log and to web server logs at /var/log/httpd, /var/log/apache2 or /var/log/nginx depending on the distribution kit and the web server you use. Carefully look through the logs to catch any possible errors.

Note: please make sure that you carefully test the performance of your extensions. If you upgrade to the latest and fresh version of Magento, the chance some extensions will work with errors or conflict with each other is rising, because not all Magento extensions providers test their modules right away after the release.

7. Primary Magento upgrade

If the careful research and testing didn’t reveal any malfunctions or you have found how to fix the errors, now it’s time to update the primary website. As the process of upgrading the Magento version and testing takes a certain time, make a fresh backup copy of the primary website, because you don’t want to recover from an old backup copy and lose the latest changes. Before backing up switch your website to maintenance mode and disable cron.

touch /home/mgtest/public_html/maintenance.flag

crontab -u mgtest -e

Save a backup copy:

cd /home/mgtest

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

mysqldump --add-drop-table -h localhost -u mgtest -p mgtest_magento | gzip > ~/magento-db.sql.gz

Repeat the Magento update procedure on your main website.

We do not recommend replacing the primary website with the sandbox store, as in that case you’re in risk of losing the data that was changed or added while testing.

Done! The last part is to turn the maintenance mode off and enable cron:

rm /home/mgtest/public_html/maintenance.flag

crontab -u mgtest –e

Mission completed! Now your shop is updated to the latest stable Magento version.

If you have already upgraded to M2, you can use our Mass Product Actions extension for more convenient catalog management.

Do you have any questions on Magento upgrade process? Welcome to the comments section. Or contact our specialists, they can help you upgrade Magento 2.2 and 2.3 to the latest version.

Update: right now the instruction isn't working because the  link isn't working and we couldn't find the replacement of it in Magento docs. As soon as we find one, we'll update the article.

Moreover, after this process, you can use Magento Optimization Service to improve the performance of your website.

You can find more information on how to update the Magento version here.

March 9, 2016
March 21, 2016
December 18, 2015
Ron Collins
March 23, 2015
Does Amasty (partners), perform upgrades like that? (Mage to 1.9?) If so... What is the charge? Thanks
Ksenia Dobreva
March 24, 2015
Hi Ron! Thanks for your question, great you decided to upgrade your Magento store. Could you please drop a line about your request to our support here? Our support managers will give you the necessary information according your case. Thanks in advance!
Hiren Modi
April 10, 2015
Wow this is really great post. i was just looking for such content on the web for my website magento version up gradation.
Ksenia Dobreva
April 14, 2015
Thanks, Hiren! Glad it worked for you.
April 17, 2015
Hi My website has alot of custom code/design changes which I have made personally, so my upgrade process isnt as simple as yours ( I can't simple install the latest version into my live), what I have done so far is installed a fresh copy of the latest version of Magento 1.9.1 on a sub-domain of my live site and hid from web crawlers/bots etc. I have imported my live DB into the new test DB, so I have the correct content to work with. I have then spent a good week or more editing the new RWD template to match the look/functionality of my current live site. I am just about there and ready for the big switch, but at this point I am a little stuck and ponding the best course of action, should i simply change the DNS setting of my main domain to point the sub-domain or Move the entire Subdomain files and DB across to the live folder? What would you suggest I do to sort this upgrade?
Ksenia Dobreva
April 17, 2015
Hi James, we would suggest the following: 1) shutdown live site (you can use Magento maintenance mode) 2) backup live site sources and database! 3) copy subdomain sources and database to live site sources/database (old sources should be deleted) But these steps do not cover the difference between the live and the test site which occurred while you were tweaking your test site. So you'll need to transfer some data from the old installation to the new one. Hope that helps!
June 27, 2015
I have always used .diff patches in order to upgrade magento and have been successful. Of course you have to apply the incremental version patches, for example: to, to, and so on. This may take a bit more time but the error you will have is minimum than direct upgrade from minor to major version.
Ksenia Dobreva
June 29, 2015
Thanks for sharing your experience!
Mubashar Aftab
October 28, 2015
Why mv public_html public_html-BAK and not cp public_html public_html-BAK
Ksenia Dobreva
October 28, 2015
Hey Mubashar, thanks for asking. Because this particular command is for data recovery, not backup.
Oleg Chehovsky
November 13, 2015
Hi Ron, We are official Amasty partners and we offer quality upgrade services with warranty
Hans Ni
February 25, 2016
Dear sir: I am Hans Ni from Woodeko company. We know that your company specialized in Magento. Now we met with Magento problem. Our is offline just because its low version. Can you help us to make it online. Perhaps you make it online by upgrading its version. We can pay some money to your for your great service. Our current version of Magento is, can you upgrade it to a new version that makes it online.
Ksenia Dobreva
February 25, 2016
Hey there and thanks for your interest and trust! Unfortunately, we don't offer Magento upgrading services right now. Wish you good luck with upgrading your store!
Melanie Johnson
September 9, 2016
Good solution to upgrade magento 1.9. Is this magento upgrade suitable for Magento 2 in 2016? It is as same as Magento upgrade extension of Litextension.
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro