Charlie Harvey

Tip: Upgrade Magento 1.5 from the commandline

One of the roles that I have at work is maintaining the Magento software that runs our ethical gift shop. I recently upgraded one of our Magento installs from to 1.5.1 using the newly introduced mage commandline tool. As regular readers will know I am a bit of a CLI freak, and was happily impressed with mage. I wrote this as it took me some googling about to find how to make mage work.

Assumptions and prerequsites

  • I’ve assumed that you’ve got ssh access to your server and that its a linux or unix server.
  • I am assuming that you are upgrading Magento 1.5 or greater. If you are upgrading 1.4, you want to use the pear tool. There is a good Magento 1.4 upgrade tutorial at hostknox if that is what you are trying to accomplish.
  • Please, please back up your database and codebase. You'll be glad of it when you set prefered_state to beta and find you’ve upgraded to 1.6 by accident. I know I did.
  • If you are in a production environment, you'll want to take down your server or put a holding message up so that customers can't access Magento whilst you work.

Let's Go!

The first thing of course is to look at the help, which is a bit terse, but describes what mage does fairly accurately. At your prompt type $ ./mage help It will output something like this Connect commands available: =========================== channel-add Add a Channel channel-alias Specify an alias to a channel name channel-delete Remove a Channel From the List channel-info Retrieve Information on a Channel channel-login Connects and authenticates to remote channel server channel-logout Logs out from the remote channel server clear-cache Clear Web Services Cache config-get Show One Setting config-help Show Information About Setting config-set Change Setting config-show Show All Settings convert Convert old magento PEAR package to new format download Download Package info Display information about a package install Install Package install-file Install Package Archive File list-available List Available Packages list-channels List Available Channels list-files List Files In Installed Package list-installed List Installed Packages In The Default Channel list-upgrades List Available Upgrades package Build Package package-dependencies Show package dependencies package-prepare Show installation information of package sync Synchronize Manually Installed Packages sync-pear Synchronize already Installed Packages by pear uninstall Un-install Package upgrade Upgrade Package upgrade-all Upgrade All Packages

If that gave you a permission denied error, you will want to give yourself execute permission on it thus $ chmod 550 mage

Sweet, we'll sync up with the repositories to make sure all our manually installed packages are up to date. $ ./mage sync

I had a big problem when I accidentally upgraded to 1.6. I found out that I should have told mage to only look for stable updates thus: $ ./mage config-set preferred_state stable Success

Now we need to set mage up to use the Mage_All_Latest package. $ ./mage install Mage_All_Latest You may see a bunch of errors like this (truncated for brevity): Error: install: Package 'Lib_Google_Checkout' is invalid './lib/googlecheckout/googlecart.php' already exists Starting to download Lib_Js_Calendar-1.51.1.tgz ... ...done: 24,627 bytes Error: install: Package 'Lib_Js_Calendar' is invalid './js/calendar/calendar-blue.css' already exists … Starting to download Lib_ZF_Locale- ... ...done: 1,522,834 bytes Error: install: Package 'Lib_ZF_Locale' is invalid './lib/Zend/Locale/Data/Translation.php' already existsStarting to download Lib_ZF_Locale- ... ...done: 1,522,834 bytes Error: install: Package 'Lib_ZF_Locale' is invalid './lib/Zend/Locale/Data/Translation.php' already exists If you do see those, you can use the --force argument. You should then see the correct thing which is: $ ./mage install Mage_All_Latest --force [Wed Aug 17 15:43:16 2011] [warn] NameVirtualHost has no VirtualHosts httpd (no pid file) not running Checking dependencies of packages Installing package community/Mage_All_Latest Package community/Mage_All_Latest installed successfully Installing package community/Interface_Adminhtml_Default Package community/Interface_Adminhtml_Default installed successfully Installing package community/Interface_Frontend_Default Package community/Interface_Frontend_Default installed successfully Installing package community/Interface_Install_Default Package community/Interface_Install_Default installed successfully Installing package community/Mage_Downloader Package community/Mage_Downloader installed successfully Installing package community/Mage_Centinel Package community/Mage_Centinel installed successfully Installing package community/Interface_Frontend_Base_Default Package community/Interface_Frontend_Base_Default installed successfully Installing package community/Phoenix_Moneybookers 1.2.5 Package community/Phoenix_Moneybookers 1.2.5 installed successfully Installing package community/Find_Feed 1.0.8 Package community/Find_Feed 1.0.8 installed successfully Installing package community/Mage_Compiler Package community/Mage_Compiler installed successfully Installing package community/Magento_Mobile Package community/Magento_Mobile installed successfully Installing package community/Mage_Core_Adminhtml Package community/Mage_Core_Adminhtml installed successfully Installing package community/Mage_Core_Modules Package community/Mage_Core_Modules installed successfully Installing package community/Lib_Js_Ext Package community/Lib_Js_Ext installed successfully Installing package community/Lib_LinLibertineFont Package community/Lib_LinLibertineFont installed successfully Installing package community/Lib_Js_TinyMCE Package community/Lib_Js_TinyMCE installed successfully Installing package community/Lib_Varien Package community/Lib_Varien installed successfully Installing package community/Lib_Google_Checkout Package community/Lib_Google_Checkout installed successfully Installing package community/Lib_Js_Calendar 1.51.1 Package community/Lib_Js_Calendar 1.51.1 installed successfully Installing package community/Lib_Js_Mage Package community/Lib_Js_Mage installed successfully Installing package community/Lib_Phpseclib Package community/Lib_Phpseclib installed successfully Installing package community/Mage_Locale_en_US Package community/Mage_Locale_en_US installed successfully Installing package community/Lib_Mage Package community/Lib_Mage installed successfully Installing package community/Lib_ZF Package community/Lib_ZF installed successfully Installing package community/Lib_Js_Prototype Package community/Lib_Js_Prototype installed successfully Installing package community/Lib_ZF_Locale Package community/Lib_ZF_Locale installed successfully Package installed: community/Mage_All_Latest Package installed: community/Interface_Adminhtml_Default Package installed: community/Interface_Frontend_Default Package installed: community/Interface_Install_Default Package installed: community/Mage_Downloader Package installed: community/Mage_Centinel Package installed: community/Interface_Frontend_Base_Default Package installed: community/Phoenix_Moneybookers 1.2.5 Package installed: community/Find_Feed 1.0.8 Package installed: community/Mage_Compiler Package installed: community/Magento_Mobile Package installed: community/Mage_Core_Adminhtml Package installed: community/Mage_Core_Modules Package installed: community/Lib_Js_Ext Package installed: community/Lib_LinLibertineFont Package installed: community/Lib_Js_TinyMCE Package installed: community/Lib_Varien Package installed: community/Lib_Google_Checkout Package installed: community/Lib_Js_Calendar 1.51.1 Package installed: community/Lib_Js_Mage Package installed: community/Lib_Phpseclib Package installed: community/Mage_Locale_en_US Package installed: community/Lib_Mage Package installed: community/Lib_ZF Package installed: community/Lib_Js_Prototype Package installed: community/Lib_ZF_Locale

So, you’ve now got an up to date Magento! Well done. You can have a look to see what upgrades are available with $ ./mage list-upgrades Next time you want to upgrade, you'll be able to type $ ./mage upgrade-all

Final thoughts

Mage is a pretty OK tool and has more capabilities than just upgrading Magento. There is a helpful using mage tutorial on Yireo if you want to explore further. I found that really very helpful. Until next time …


  • Be respectful. You may want to read the comment guidelines before posting.
  • You can use Markdown syntax to format your comments. You can only use level 5 and 6 headings.
  • You can add class="your language" to code blocks to help highlight.js highlight them correctly.

Privacy note: This form will forward your IP address, user agent and referrer to the Akismet, StopForumSpam and Botscout spam filtering services. I don’t log these details. Those services will. I do log everything you type into the form. Full privacy statement.