Tuesday, September 03, 2013

Upgrading SugarCRM command-line style

Where do we start? If you are here, chances are you know what SugarCRM is. For the lazy amongst you (like me!), the CRM in SugarCRM stands for Customer relationship management, which can be seen as a way to keep track of everything related to your customers: address, frequency and types of support questions, infomercials you sent to them, and so on.

If I can go on a detour, the concept is interesting because if you forget about the "customer" part of the acronym, you as an individual can apply it to other things. Like dealing with the IRS and other government organizations, your landlord (yes you should, trust me), job hunting, and so on. Ok, time to merge back with the main traffic.

The reason I am writing this is, as the title hints at, upgrading SugarCRM. There are two ways of upgrading this program. The first one is using the Upgrade Wizard and the other is using what they call a Silent Upgrade. Both start the same way:

  1. Find out the version you currently have installed and the one you want to upgrade to. At the time I wrote this, I had 6.5.9 installed and wanted to go to 6.5.14.
  2. Go to http://sourceforge.net/projects/sugarcrm/ and look for the upgrade file. In my case, it was in the http://sourceforge.net/projects/sugarcrm/files/1%20-%20SugarCRM%206.5.X/SugarCommunityEdition-6.5.X%20Upgrade/ directory. And the file I wanted was SugarCE-Upgrade-6.5.x-to-6.5.14.zip.
  3. Place the zip file somewhere the user running the web server can access. Since I am using Linux and am quite lazy, the location of choice was /tmp.

Now, if you were going to use the Wizard, you would follow something like http://www.siteground.com/tutorials/sugarcrm/sugarcrm-upgrade.htm... and then SugarCRM would then hang for an hour or so. I did try following the instructions in http://support.sugarcrm.com/04_Find_Answers/02KB/02Administration/100Install/Troubleshooting_Upgrade_Wizard_System_Check to no avail. I posted about this on their support site but so far no replies. So, time for a silent install.

Doing it command-line style

Don't get me wrong: using the command line to upgrade SugarCRM is not only to avoid sitting in your thumbs for an hour just to see it fail. It does not require the person doing the upgrade be a SugarCRM admin; if you can run as the web server user, you are good. You do not even need to be a user with root rights. Privilege separation in action babe!

So we go back to the steps we used to get the zip file (see above) and then add a few more:

  1. In the same directory you downloaded the upgrade file from, find a file called silentUpgrade-CE-X.Y.Z.zip where X, Y, and Z match the version you are upgrading to. In my case that was silentUpgrade-CE-6.5.14.zip.
  2. Download the silentUpgrade file you found in the previous step to the same convenient location you downloaded the upgrade file to. Once again in my case that was /tmp.
  3. Unzip the silentUpgrade file, but leave the upgrade one alone. If you are using /tmp as the staging directory, you should end up with something like this
    root@sugarcrm:/tmp# ls -lh /tmp/
    total 4.4M
    -rw-r--r-- 1 root     root      25K Jun 21 02:01 silentUpgrade_dce_step1.php
    -rw-r--r-- 1 root     root      33K Jun 21 02:01 silentUpgrade_dce_step2.php
    -rw-r--r-- 1 root     root     4.4K Jun 21 02:01 silentUpgrade.php
    -rw-r--r-- 1 root     root      42K Jun 21 02:01 silentUpgrade_step1.php
    -rw-r--r-- 1 root     root      21K Jun 21 02:01 silentUpgrade_step2.php
    -rw-r--r-- 1 root     root     4.9K Jun 21 02:01 SILENTUPGRADE.txt
    -rw-r--r-- 1 root     root     4.2M Aug 28 09:59 SugarCE-Upgrade-6.5.x-to-6.5.14.zip
    root@sugarcrm:/tmp# 
    Note that I cheated here and am running as root. You can unzip those files as yourself as long as you have permission to set their group id to the web server user (in Ubuntu that would be www-data).
  4. Run silentupgrade, telling it where to store its log file. Just to be different, I decided my log file shall be /tmp/sucre.log:
    sudo -u www-data php -f /tmp/silentUpgrade.php /tmp/SugarCE-Upgrade-6.5.x-to-6.5.14.zip /tmp/sucre.log /var/www/sugar/ admin
  5. If successful, you should see a message like this:
    ********************************************************************
    ***************This Upgrade process may take sometime***************
    ********************************************************************
    
    ********************************************************************
    *************************** SUCCESS*********************************
    ********************************************************************
    ******** If your pre-upgrade Leads data is not showing  ************
    ******** Or you see errors in detailview subpanels  ****************
    ************* In order to resolve them  ****************************
    ******** Log into application as Administrator  ********************
    ******** Go to Admin panel  ****************************************
    ******** Run Repair -> Rebuild Relationships  **********************
    ********************************************************************
    If you see an error, check the log file you created (in this case /tmp/sucre.log) for clues.

If you are curious, the actual running of silentupgrade took under a minute once all the files were properly downloaded and unzipped. I don't know about you but to me that is a big improvement from waiting an hour to find out it did not work.

References