The best way to update Magento via SSH

by Mike

When a client hires us to develop their website and it contains an ecommerce element, we typically take a close look at Magento. We like developing for Magento because it had an enormous amount of features and capabilities, and ends up with a much nicer result than what we have seen with many OScommerce and ZenCart solutions.

Recently, one of our development servers had a very old version of Magento on it, and before we could start development on a new extension for a client, we had to upgrade it.

This is the script that I use whenever I am upgrading Magento:

wget http://www.magentocommerce.com/downloads/assets/1.5.0.1/magento-1.5.0.1.tar.gz
tar -zxvf magento-1.5.0.1.tar.gz
cd magento
tar cf - . |(cd ..; tar xvf -)
chmod -R o+w media var
chmod o+w app/etc
rm -rf magento/ magento-1.5.0.1.tar.gz

Let’s take a look at what is happening here.

First, we download the next newest version of Magento (click the “Release Archives” tab) and untar it. While theoretically Magento will cleanly upgrade from any old version to any new version, I’ve had the best luck when I don’t skip versions.

wget http://www.magentocommerce.com/downloads/assets/1.5.0.1/magento-1.5.0.1.tar.gz
tar -zxvf magento-1.5.0.1.tar.gz

Next, we do my favorite part. First go into the new magento directory, and then use tar to gather all of the files, retaining permissions and ownership information, and untar them into the root directory of the site.

cd magento
tar cf - . |(cd ..; tar xvf -)

Then we just have to set the directories that have to have write access.

chmod -R o+w media var
chmod o+w app/etc

And finally we cleanup the excess Magento directory and tar file.

rm -rf magento/ magento-1.5.0.1.tar.gz

After you have run this, visit the home page of the site to allow it to go through the database upgrade process. I’ve received errors while trying to upgrade the database in the past. Usually these can be solved by deleting the file mentioned in the error.

Then, just like shampoo, you’ll want to repeat the process, changing the version numbers on all three lines until your site is at the most current stable version.

I can’t guarantee that this will solve all of your upgrade woe’s, but I can tell you that this has helped me limit my woes to just those caused by deprecated code.

About Mike


Construction worker turned snow plower turned web professional; Mike offers an interesting blend marketing savvy, business sense, and technological geekiness. With more than 10 years of experience developing websites, and expertise with the most modern standards and technologies, Mike creates breathtaking web projects that result in increased sales for clients. Mike lives with his wife and two Labrador Retrievers in Essexville, Michigan.

Leave a Reply