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 1.5.0.1 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 http://connect20.magentocommerce.com/community 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-1.11.1.0.tgz ...
...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-1.11.1.0.tgz ...
...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 http://connect20.magentocommerce.com/community Mage_All_Latest --force [Wed Aug 17 15:43:16 2011] [warn] NameVirtualHost 127.0.0.1:443 has no VirtualHosts httpd (no pid file) not running Checking dependencies of packages Installing package community/Mage_All_Latest 1.5.1.0.1 Package community/Mage_All_Latest 1.5.1.0.1 installed successfully Installing package community/Interface_Adminhtml_Default 1.5.1.0 Package community/Interface_Adminhtml_Default 1.5.1.0 installed successfully Installing package community/Interface_Frontend_Default 1.5.1.0 Package community/Interface_Frontend_Default 1.5.1.0 installed successfully Installing package community/Interface_Install_Default 1.5.1.0 Package community/Interface_Install_Default 1.5.1.0 installed successfully Installing package community/Mage_Downloader 1.5.0.1 Package community/Mage_Downloader 1.5.0.1 installed successfully Installing package community/Mage_Centinel 1.5.0.0 Package community/Mage_Centinel 1.5.0.0 installed successfully Installing package community/Interface_Frontend_Base_Default 1.5.1.0 Package community/Interface_Frontend_Base_Default 1.5.1.0 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 1.5.0.0 Package community/Mage_Compiler 1.5.0.0 installed successfully Installing package community/Magento_Mobile 1.5.0.0.21.0 Package community/Magento_Mobile 1.5.0.0.21.0 installed successfully Installing package community/Mage_Core_Adminhtml 1.5.1.0 Package community/Mage_Core_Adminhtml 1.5.1.0 installed successfully Installing package community/Mage_Core_Modules 1.5.1.0 Package community/Mage_Core_Modules 1.5.1.0 installed successfully Installing package community/Lib_Js_Ext 1.5.0.0 Package community/Lib_Js_Ext 1.5.0.0 installed successfully Installing package community/Lib_LinLibertineFont 2.8.14.0 Package community/Lib_LinLibertineFont 2.8.14.0 installed successfully Installing package community/Lib_Js_TinyMCE 3.3.7.0 Package community/Lib_Js_TinyMCE 3.3.7.0 installed successfully Installing package community/Lib_Varien 1.5.1.0 Package community/Lib_Varien 1.5.1.0 installed successfully Installing package community/Lib_Google_Checkout 1.5.0.0 Package community/Lib_Google_Checkout 1.5.0.0 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 1.5.1.0 Package community/Lib_Js_Mage 1.5.1.0 installed successfully Installing package community/Lib_Phpseclib 1.5.0.0 Package community/Lib_Phpseclib 1.5.0.0 installed successfully Installing package community/Mage_Locale_en_US 1.5.1.0 Package community/Mage_Locale_en_US 1.5.1.0 installed successfully Installing package community/Lib_Mage 1.5.0.0 Package community/Lib_Mage 1.5.0.0 installed successfully Installing package community/Lib_ZF 1.11.1.0 Package community/Lib_ZF 1.11.1.0 installed successfully Installing package community/Lib_Js_Prototype 1.6.0.3.4 Package community/Lib_Js_Prototype 1.6.0.3.4 installed successfully Installing package community/Lib_ZF_Locale 1.11.1.0 Package community/Lib_ZF_Locale 1.11.1.0 installed successfully Package installed: community/Mage_All_Latest 1.5.1.0.1 Package installed: community/Interface_Adminhtml_Default 1.5.1.0 Package installed: community/Interface_Frontend_Default 1.5.1.0 Package installed: community/Interface_Install_Default 1.5.1.0 Package installed: community/Mage_Downloader 1.5.0.1 Package installed: community/Mage_Centinel 1.5.0.0 Package installed: community/Interface_Frontend_Base_Default 1.5.1.0 Package installed: community/Phoenix_Moneybookers 1.2.5 Package installed: community/Find_Feed 1.0.8 Package installed: community/Mage_Compiler 1.5.0.0 Package installed: community/Magento_Mobile 1.5.0.0.21.0 Package installed: community/Mage_Core_Adminhtml 1.5.1.0 Package installed: community/Mage_Core_Modules 1.5.1.0 Package installed: community/Lib_Js_Ext 1.5.0.0 Package installed: community/Lib_LinLibertineFont 2.8.14.0 Package installed: community/Lib_Js_TinyMCE 3.3.7.0 Package installed: community/Lib_Varien 1.5.1.0 Package installed: community/Lib_Google_Checkout 1.5.0.0 Package installed: community/Lib_Js_Calendar 1.51.1 Package installed: community/Lib_Js_Mage 1.5.1.0 Package installed: community/Lib_Phpseclib 1.5.0.0 Package installed: community/Mage_Locale_en_US 1.5.1.0 Package installed: community/Lib_Mage 1.5.0.0 Package installed: community/Lib_ZF 1.11.1.0 Package installed: community/Lib_Js_Prototype 1.6.0.3.4 Package installed: community/Lib_ZF_Locale 1.11.1.0
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 …