15

The standard upgrade process for CiviCRM is quite a complex process according to the instructions in the wiki.

Is it easier to use drush to upgrade CiviCRM? If so, how do you do this? I couldn't find any up to date documentation on this, so if you are able to point me in the right direction that would be greatly appreciated.

Thanks for your help.

1

5 Answers 5

17

To answer my own question, it is possible to update CiviCRM with drush but this isn't completely straightforward either. For the benefit of others I post the steps I took below.

These steps must be executed in the root directory of Drupal:

  1. put the site into maintenance mode: drush vset maintenance_mode 1
  2. clear all caches: drush cc all
  3. take a full backup of site and test that this works on a development server
  4. upgrade CiviCRM: drush cvup --tarfile=<path to tarfile> --backup-dir=<path to backup dir>
  5. upload the latest version of the localisation files and extract to sites/all/modules/civicrm/l10n
  6. delete contents of sites/default/files/civicrm/templates_c/
  7. take the site out of maintenance mode:drush vset maintenance_mode 0
  8. clear all caches: drush cc all

Notes:

  • I was upgrading from CiviCRM 4.6.6 to 4.6.7. If you are upgrading from an older version you may find that there are more steps.
  • The first time I tried to upgrade at step 4 this resulted in an error 'Your database has already been upgraded to CiviCRM 4.6.6' (note that I was trying to upgrade to 4.6.7). Repeating this step resulted in success. This bug appears to have been fixed.
  • It may be easier to manually delete and replace the civicrm folder as Laryn suggests.
  • I'm not sure if step 6 is really necessary.
1
  • 2
    Yeah, this looks more complicated than Laryn's approach (which I also use). i.e. use drush for the civicrm db update, but not for replacing the code. The drush civicrm db update is definitely worthwhile (before I used it, i'd often get breakage due to some smarty template, using means the db updates can get done without actually trying to generate any pages, which makes a lot of sense).
    – Alan Dixon
    Commented Aug 31, 2015 at 15:10
9

You can get a list of Civi-related Drush commands simply by typing drush on the command line. Excerpt:

All commands in civicrm: (civicrm)
civicrm-api (cvapi)         CLI access to CiviCRM APIs. It can return pretty-printor json formatted data.                                                                
civicrm-enable-debug        Enable CiviCRM Debugging.                                                                                                                    
civicrm-ext-disable (ced)   Disable a CiviCRM extension.                                                                                                                                                                                                                                                                           
civicrm-ext-install (cei)   Install a CiviCRM extension.                                                                                                                                                                                                                                                                            
civicrm-ext-list (cel)      List of CiviCRM extensions enabled.                                                                                                                                                                                                                                                                   
civicrm-ext-uninstall (ceui)Uninstall a CiviCRM extension.                                                                                                                                                                                                                                                                     
civicrm-install             Install a new instance of CiviCRM.                                                                                                                                                                                                                                                                    
civicrm-member-records      Run the CiviMember UpdateMembershipRecord cron (civicrm-member-records).                                                                                                                                                                                                                                 
civicrm-process-mail-queue  Process pending CiviMail mailing jobs.                                                                                                                                                                                                                                                                
civicrm-rest (cvr)          Rest interface for accessing CiviCRM APIs. It can return xml or json formatted data.                                                         
civicrm-restore             Restore CiviCRM codebase and database back from the specified backup directory.                                                              
civicrm-sql-cli (cvsqlc)    Open a SQL command-line interface using CiviCRM's credentials.                                                                                                                                                                                                                                      
civicrm-sql-conf            Print CiviCRM database connection details.                                                                                                   
civicrm-sql-connect         A string for connecting to the CiviCRM DB.                                                                                                   
civicrm-sql-dump            Exports the CiviCRM DB as SQL using mysqldump.                                                                                               
civicrm-sql-query           Execute a query against the CiviCRM database.                                                                                                
civicrm-update-cfg (cvupcfg)Update config_backend to correct config settings, especially when the CiviCRM site has been cloned / migrated.                                                                                                                                                                                           
civicrm-upgrade (cvup)      Replace CiviCRM codebase with new specified tarfile and upgrade database by executing the CiviCRM upgrade process - civicrm/upgrade?reset=1.                                                                                                                                                          
civicrm-upgrade-db (cvupdb) Execute the civicrm/upgrade?reset=1 process from the command line.                                                                           

Personally I usually download the tarfile manually, replace the civicrm directory in the modules folder (backing up as needed, e.g. drush civicrm-sql-dump > ~/filename.sql) and then use drush cvupdb to run the database upgrade.

Practice on a dev server first, though! :)

4
  • So if I understand it correctly, I would need to download the latest version of CiviCRM and then run this command drush civicrm-upgrade --tarfile=~/civicrm-4.6.7-drupal.tar.gz. Is that right? Commented Aug 20, 2015 at 16:45
  • 1
    Looks right to me, but as I said I usually use a variation with portions done manually. Post back if this works as you expected!
    – Laryn
    Commented Aug 20, 2015 at 17:13
  • Yes, but it wasn't completely straightforward. I'll post a full answer with more detail. Commented Aug 21, 2015 at 11:58
  • 1
    Thanks, this should be the accepted answer, it is super easy and straightforward.
    – DrCord
    Commented Feb 5, 2016 at 3:35
2

another helpful thing that I do when using drush for civi upgrades: since drush does not give you any information about where in the process the upgrade is (the GUI has the progress bar that says what version it is at) I open another ssh session to the server and use drush civicrm-sql-cli to get into the sql console with the right database. Then as the upgrade runs in one terminal I repeatedly run the following query to follow the progress -- especially in upgrades that span multiple versions:

select version from civicrm_domain;
2

I use the following for Drupal 7 which I find a straightforward process:

(I do this on a development copy of the site first to check for issues)

  1. cd public_html/sites/all/modules // go to modules folder for site
  2. wget https://download.civicrm.org/latest/civicrm-STABLE-drupal.tar.gz //get latest
  3. drush vset maintenance_mode 1 //put site into maintenance_mode
  4. rm -rf civicrm //delete civi (make sure you are logged in!)
  5. tar -xvzf civicrm-STABLE-drupal.tar.gz //extract Civi
  6. rm civicrm-STABLE-drupal.tar.gz //delete tarball
  7. cv upgrade:db //upgrade civi db or use drush civicrm-upgrade-db
  8. cv flush //flush system files
  9. drush vset maintenance_mode 0 //put site online

I know you asked for Drush commands but I thought I would add my process as it may be helpful to others. It uses a mixture of drush and cv. cv is a Civi command line utility like drush and is easy to install. If you can install drush you can certainly install cv. Get it from https://github.com/civicrm/cv.

1
  • Thanks! This is an old question. At the time I was trying to understand if the process could be completed just using drush. However, a different (and possibly more useful?) question would be 'How can I upgrade CiviCRM on Drupal'. In which case your answer would certainly make sense. Commented Jan 20, 2021 at 9:56
1

we have our own shell script for both Drupal and Wordpress that automatize everything and takes less than 10" to upgrade CiviCRM. It was inspired amongst other sources by this post.

The script has been developed for Plesk but it's easy to modify: see on our Github

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.