It would be great if you had a button in the admin to do the update, but it's not that simple. You may be thinking, "but what about Magento Connect?" He's not that efficient, believe me. Today in this tutorial I will explain how to upgrade your Magento store. This tutorial has been tested with version to

For this tutorial you will need:

* SSH access to server
* Shell command knowledge
* Knowledge of Magento
* Knowledge of MySQL

If you do not have the necessary knowledge STOP now and hire someone to do your update. This tutorial CAN and WILL break your store if you do not know what you are doing. Any problem caused by this tutorial is not the responsibility of MagentoBR and there is no guarantee of operation or support!
We recommend that the upgrade be done in the development environment and not in the production environment! Run multiple tests in your development environment before you upgrade your production environment.
First of all you need to BACKUP!

For this step you need to check the path to your store.
My example: /var/www/vhosts/
Open the folder /var/www/vhosts:

cd /var/www/vhosts

Now that we are going to save the entire folder:

tar -cvf backup_store.tar

Now we have the backup of the files, we need to make a backup of the database. You need to know the name of the database you use, for our example will be: store_magento.
Run the following command (you will need to enter the password):

mysqldump -u root -p store_magento > store_magentosql

Now that we have the backup we will update Magento. First open the folder where Magento is.

cd /var/www/vhosts/

Our second step is to download Magento 1.9:

tar xvf magento-

Let's open the .htaccess file and change the maximum memory it can use and the maximum execution time of PHP. Be very careful with numbers, decrease or increase if necessary.

php_value memory_limit 2048M
php_value max_execution_time 90000

Now let's clear all caches and update apache / nginx. If you use Ubuntu / Debian use apache2, in the example we use CentOS / RHEL. If you have Varnish add another line with Varnish.

rm -rf var/cache/* var/session/* var/locks/* var/full_page_cache/* tmp/*
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
service httpd restart

Let's now remove the downloader and app/design/frontend/base folder. We will remove these files so that you have no problems with files that have changed. Run the command:

rm -rf downloader
rm -rf app/design/frontend/base

Our next step is to copy the folders we removed directly from the new version, run the command:

cp -a magento/downloader .
cp -a magento/app/design/frontend/base/ app/design/frontend/

Let's also use the mage file of the new version. Execute:

cp magento/mage .
chmod 755 ./mage

Before doing the upgrade we need to make sure that Connect is set to Stable. Run the command:

./mage config-set preferred_state stable

Now let's copy all the new Magento files. To make sure all files have been copied, let's run the same command 3 times. Run the following command:

for i in {1..3}; do yes | cp -Rf magento/* .; done

Now we will do the update using mage, to do this execute the command:

./mage mage-setup .
./mage sync --force
./mage install Mage_All_Latest --force

After finishing the update we will clear the cache and change the permission of the mage file. Execute:

rm -rf var/cache/* var/session/* var/locks/* var/full_page_cache/* tmp/*
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
chmod 755 mage

Let's update store contents. You may encounter an error in this step, ignore and continue with the tutorial. Run the command:

php shell/indexer.php reindexall

Be calm, we have a long road still. Let's now upgrade the modules that are not the base of Magento.

./mage upgrade-all --force

Now that we've finished updating the Magento files, let's set the correct permissions:

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 777 {} \;
chmod 755 mage
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
chmod -R 777 var/package var/locks var/report var/export downloader

Remember to update the user permission in the Magento folder. In this example I will use apache (CentOS / RHEL). For Ubuntu / Debian use www-data:

chown -R apache:apache *

There, the ARCHIVES update is complete. The database is missing. This part is automated, you just need to open your store.
Soon you will see that the store will not open, only read and nothing. This means that the database is being updated. This step may take VARIOUS minutes and you will have to be patient.
I recommend that you go watch TV, play something, eat, whatever. For you to see if something is happening in your database you can run the command:

watch -n 5 mysqladmin -p processlist

If an error occurs, as it happened to me, the error will appear on the homepage. Usually there is some table in the database that does not exist, this information will be in error. We need to create this table in the database, but we need to know what the structure is. To do so, visit the following site that contains all the tables:

Do the search for the table that is in the error and copy the part referring to the table. Now using some MySQL administration system (phpMyAdmin) you can create the required table using the information that was copied.
After creating the table you can update the homepage of your store and you will see that the page will read again without opening. If the store stops working, check the database if something is happening. It may be that the maximum execution time of PHP is finished.

Once you have been updated you will need to remove some files from Google Checkout due to an error that happens when opening the admin, run the command below:

rm -rf app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml
rm -rf app/code/core/Mage/GoogleCheckout/etc/system.xml
rm -rf app/code/core/Mage/GoogleCheckout/etc/wsdl.xml
rm -rf app/code/core/Mage/GoogleCheckout/etc/wsi.xml

We will update the indexes again and this time no errors should appear:

php shell/indexer.php reindexall

Your store should already be without problems to access and the admin should already be working. But soon at the beginning of this tutorial we remove the app/design/frontend/base folder and several modules place their files here. You will need to upload your module files here.


I hope this tutorial helped you upgrade your store.