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 188.8.131.52 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.
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
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):
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
install: Package 'Lib_Js_Calendar' is invalid
'./js/calendar/calendar-blue.css' already exists
Starting to download Lib_ZF_Locale-184.108.40.206.tgz ...
...done: 1,522,834 bytes
install: Package 'Lib_ZF_Locale' is invalid
'./lib/Zend/Locale/Data/Translation.php' already existsStarting to download Lib_ZF_Locale-220.127.116.11.tgz ...
...done: 1,522,834 bytes
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 18.104.22.168.1 Package community/Mage_All_Latest 22.214.171.124.1 installed successfully Installing package community/Interface_Adminhtml_Default 126.96.36.199 Package community/Interface_Adminhtml_Default 188.8.131.52 installed successfully Installing package community/Interface_Frontend_Default 184.108.40.206 Package community/Interface_Frontend_Default 220.127.116.11 installed successfully Installing package community/Interface_Install_Default 18.104.22.168 Package community/Interface_Install_Default 22.214.171.124 installed successfully Installing package community/Mage_Downloader 126.96.36.199 Package community/Mage_Downloader 188.8.131.52 installed successfully Installing package community/Mage_Centinel 184.108.40.206 Package community/Mage_Centinel 220.127.116.11 installed successfully Installing package community/Interface_Frontend_Base_Default 18.104.22.168 Package community/Interface_Frontend_Base_Default 22.214.171.124 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 126.96.36.199 Package community/Mage_Compiler 188.8.131.52 installed successfully Installing package community/Magento_Mobile 184.108.40.206.21.0 Package community/Magento_Mobile 220.127.116.11.21.0 installed successfully Installing package community/Mage_Core_Adminhtml 18.104.22.168 Package community/Mage_Core_Adminhtml 22.214.171.124 installed successfully Installing package community/Mage_Core_Modules 126.96.36.199 Package community/Mage_Core_Modules 188.8.131.52 installed successfully Installing package community/Lib_Js_Ext 184.108.40.206 Package community/Lib_Js_Ext 220.127.116.11 installed successfully Installing package community/Lib_LinLibertineFont 18.104.22.168 Package community/Lib_LinLibertineFont 22.214.171.124 installed successfully Installing package community/Lib_Js_TinyMCE 126.96.36.199 Package community/Lib_Js_TinyMCE 188.8.131.52 installed successfully Installing package community/Lib_Varien 184.108.40.206 Package community/Lib_Varien 220.127.116.11 installed successfully Installing package community/Lib_Google_Checkout 18.104.22.168 Package community/Lib_Google_Checkout 22.214.171.124 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 126.96.36.199 Package community/Lib_Js_Mage 188.8.131.52 installed successfully Installing package community/Lib_Phpseclib 184.108.40.206 Package community/Lib_Phpseclib 220.127.116.11 installed successfully Installing package community/Mage_Locale_en_US 18.104.22.168 Package community/Mage_Locale_en_US 22.214.171.124 installed successfully Installing package community/Lib_Mage 126.96.36.199 Package community/Lib_Mage 188.8.131.52 installed successfully Installing package community/Lib_ZF 184.108.40.206 Package community/Lib_ZF 220.127.116.11 installed successfully Installing package community/Lib_Js_Prototype 18.104.22.168.4 Package community/Lib_Js_Prototype 22.214.171.124.4 installed successfully Installing package community/Lib_ZF_Locale 126.96.36.199 Package community/Lib_ZF_Locale 188.8.131.52 installed successfully Package installed: community/Mage_All_Latest 184.108.40.206.1 Package installed: community/Interface_Adminhtml_Default 220.127.116.11 Package installed: community/Interface_Frontend_Default 18.104.22.168 Package installed: community/Interface_Install_Default 22.214.171.124 Package installed: community/Mage_Downloader 126.96.36.199 Package installed: community/Mage_Centinel 188.8.131.52 Package installed: community/Interface_Frontend_Base_Default 184.108.40.206 Package installed: community/Phoenix_Moneybookers 1.2.5 Package installed: community/Find_Feed 1.0.8 Package installed: community/Mage_Compiler 220.127.116.11 Package installed: community/Magento_Mobile 18.104.22.168.21.0 Package installed: community/Mage_Core_Adminhtml 22.214.171.124 Package installed: community/Mage_Core_Modules 126.96.36.199 Package installed: community/Lib_Js_Ext 188.8.131.52 Package installed: community/Lib_LinLibertineFont 184.108.40.206 Package installed: community/Lib_Js_TinyMCE 220.127.116.11 Package installed: community/Lib_Varien 18.104.22.168 Package installed: community/Lib_Google_Checkout 22.214.171.124 Package installed: community/Lib_Js_Calendar 1.51.1 Package installed: community/Lib_Js_Mage 126.96.36.199 Package installed: community/Lib_Phpseclib 188.8.131.52 Package installed: community/Mage_Locale_en_US 184.108.40.206 Package installed: community/Lib_Mage 220.127.116.11 Package installed: community/Lib_ZF 18.104.22.168 Package installed: community/Lib_Js_Prototype 22.214.171.124.4 Package installed: community/Lib_ZF_Locale 126.96.36.199
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
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 …