Upgrades and maintenance

As with any actively developed software project, you should anticipate the need to upgrade to latest revisions and versions on a periodic basis, and perform regular maintenance on your system. Anticipating these needs and planning accordingly will greatly improve your long-term experience with CiviCRM.

Version and revision upgrades

The CiviCRM project follows conventional terminology for software releases:

  • Versions: Represents significant software releases with new functionality
  • Revisions: Represents minor releases and addresses bug, security, and functionality fixes

The core development team aggressively releases two to three major versions each year, and three to four minor revisions in between the major releases. The version number follows the conventional format as well: 3.2.4 = version 3.2, revision 4. You may track bugs and issues reported for a certain version through the CiviCRM website.

Since revisions typically correct bugs or address security issues, you should ideally implement them as soon as they are released. Revisions generally require minimal modifications to your database structure or data; so the potential risk of running into any issues is less.

Before conducting any revision upgrade, back up your database and file system and test to ensure the integrity of the backup files. It is particularly important to have a reliable backup of your database, as you will need to restore the database to the previous version should there be any problems during the database upgrade script. It is also recommended that you perform upgrades on a development server before implementing on your live server. We consider it essential to use a development or staging server for sites that have custom templates and code.

Finally, if you have made any modifications to CiviCRM files, including template (.tpl) and CSS files, be sure to have a good record of your changes. You will need to review the changes against the new codebase and may need to adjust them. This is particularly true for major version upgrades, as the files are more likely to have significant changes.

CiviCRM provides some helpful tools for maintaining custom development work:

  • Hooks: Hooks are placeholders in the CiviCRM code where you can inject your own custom code. The benefit of hooks is that you are not actually modifying core files—your custom code is maintained separately and is injected into the code in the appropriate place. For more details on using hooks, visit: http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification.
  • Override Directories: Override directories are folders located outside of the core files where you can have modified versions of core files. CiviCRM first looks to see if the file exists in the override directory, and if so, uses it. Override directories can be used for both PHP and .tpl (template) files. The override directories are configured in: Administer | Configure | Global Settings | Directories.
  • extras.css: The .../civicrm/css/ folder contains all of the CSS files used by CiviCRM. The extras.css (empty by default) file will override the other CSS files, allowing you to maintain style modifications separate from the core file.

Joomla! upgrades

Version and revision upgrades for Joomla! follow the same steps as an initial installation, with the addition of one step - an upgrade of the database to the current CiviCRM version. You must upload the new version to a location on your server (we recommend using the /tmp/ directory), unpack it, and use the Install from Directory option in the Extensions | Install/Uninstall tool (refer to the Joomla! installation steps above for a more detailed walk-through).

After triggering the installation, you should receive a notification that the database must be updated to the current version. After clicking to upgrade, you should see a successful upgrade message, a link to visit the CiviCRM dashboard page where the menu will be rebuilt, and possibly a message about any configuration changes that could impact your site.

If the upgrade did not complete successfully, you will need to do some troubleshooting to determine the cause.

One possible problem may be restrictive permissioning on your filesystem that prohibited the installation script from overwriting existing files. This is generally easy to notice because the database upgrade script will not report a change from the previous version to the current, and the versioning in the footer region and Joomla! extension manager will not reflect the new version. If this happens, you will need to address the permissioning on your filesystem, or first uninstall CiviCRM and then reinstall it. Note that uninstalling/reinstalling will preserve your data, but you will need to review your configuration settings and must reset any menu items pointing to CiviCRM pages.

It is also possible that you may run into problems during the database upgrade step. For large databases or lower-end server environments, the script could potentially timeout in the middle of processing, resulting in a half-upgraded database. If this happens, you will need to restore the database from your backup and reinitiate the upgrade. If the problem persists, you may need to manually implement the SQL scripts through PHPMyAdmin or the command line interface. You can find the scripts in the /civicrm/sql/ folder in the installation package.

If the database upgrade script yields an error with the backtrace logs, it is likely there is a problem with the structure or foreign key relationships in your current database. The backtrace error will provide some guidance as to the source of the problem. You will need to resolve the problem in the current database before retrying the installation process.

If you continue to have trouble with the database upgrade, complete the following steps to ensure the database schema for your current (pre-upgrade) version is structured correctly:

  1. Back up the data (only) for your current version of the database. This may require you to re-import the backup you made at the beginning of this process, and then export with just the data (no structure).
  2. Create a new, empty database.
  3. Import the database structure from your current version of CiviCRM, as found in the installation package. This is found in the location .../civicrm/sql/civicrm.mysql. Importing this to a clean database ensures you have the correct structure for your current version.
  4. Import the data from your current version to this clean database. You should now have your current site's data in a clean structure.

    Note

    Note that if your site contained custom data, these will be stored in their own tables and not included in the clean structure imported in the previous step. You will need to import the structure and data for custom tables.

  5. Now use this new database containing a clean structure and current site data to rerun the upgrade process. That may require dumping the tables in your current live database and replacing them with the tables in this new database.
  6. Proceed with the installation and database upgrade.

These steps should ensure that the CiviCRM database upgrade script is working with an accurate structure in your current database.

After completing the upgrade, open your civicrm.settings.php file and confirm that the site key value is intact (used for cron jobs, as described above).

Drupal upgrades

The upgrade process for Drupal requires a number of steps to complete successfully. As in the Installation in Drupal subsection of the Installing CiviCRM section, we will describe how to upgrade in two ways: with a browser and FTP, and using Drush:

  1. Take the site offline by following these steps:
    • Log in as user 1.
    • Go to Administer | Site Configuration | Site Maintenance.
    • Click on Off-line. Review and edit the Site off-line message as appropriate.
    • Click on Save configuration.
  2. If your home page is a CiviCRM page:
    • Click on Administer | Site Configuration | Site Information.
    • Note the Default front page, so that it can be restored later in the upgrade, perhaps by taking a screenshot.
    • Change the Default front page to node.
    • Click Save configuration.
  3. If you are using any CiviCRM integration or extension modules:
    • Click on Administer | Site Building | Modules.
    • Note the integration or extension modules being used, perhaps by taking a screenshot.
    • Uncheck the Enabled? box for all relevant modules (for example, CiviMember Roles Sync).
    • Click on Save configuration.
  4. List and take note of the command-line scripts that are currently enabled:
    
    $ ls /path_to_docroot/sites/all/modules/civicrm/bin/*.php > /path_to_safe_dir/SavedListOfEnableScripts.txt
    
  5. Download the new CiviCRM files:
    
    $ wget -O /path_to_docroot/sites/all/modules/civicrm.tar.gz http://sourceforge.net/projects/civicrm/files/civicrm-stable/3.2.0/civicrm-3.2.0-drupal.tar.gz/download
    
  6. Using Drush:
    
    $ cd /path_to_docroot/
    $ drush civicrm-upgrade --tarfile=sites/all/modules/civicrm-3.2.0-drupal.tar.gz
    
  7. Using the non-Drush method:
    • Back up your CiviCRM and Drupal databases.
    • For example, from a command line,
    
    $ mysqldump -uCivicrmDbUser -pCivicrmDbPassword -h localhost --databases yourDomain_dru yourDomain_civ > yourDomain.backup.mysql
    
    • Backup your CiviCRM files:
    • For example, from a command line,
    
    $ cd /path_to_docroot/sites/; tar -czf civicrm.files.old.tgz all/modules/civicrm yourDomain/files/civicrm
    
    • Delete the CiviCRM core files:
    
    $ cd all/modules
    $ rm -rf civicrm
    
  8. Untar the files by replacing 3.2.0 with the appropriate filename from above:
    
    $ tar -xzf civicrm-3.2.0-drupal.tar.gz
    
  9. Verify that the permissions are still correct for the files directory in either the default or yourDomain.org site directories as appropriate:
    
    $ chmod -R 777 /path_to_docroot/sites/yourDomain.org/files
    
  10. Run the upgrade through the browser as follows:
    • Log in as an administrator to your site:
    • Navigate to http://yourDomain.org/civicrm/upgrade?reset=1 if clean URLs are enabled, or navigate to http://yourDomain.org/?q=civicrm/upgrade&reset=1 if clean URLs are not enabled.
    • Click on Upgrade Now.
    • If there are any problems, go to the appropriate CiviCRM forum for help: http://forum.civicrm.org/index.php/board,8.0.html.
    • If there are no problems, click on Return to CiviCRM home page to rebuild CiviCRM menus and go to the dashboard.
  11. Re-enable CiviCRM integration and extension modules:
    • Click Administer | Site Building | Modules.
    • Check Enabled beside the appropriate integration and extension modules that you noted as you disabled them previously.
    • Click Save configuration.
    • If you have re-enabled Views integration:

      Click on Administer | Site Building | Views | Tools.

      Click on Clear Views' cache button.

  12. Restore CiviCRM as the home page, if appropriate:
    • Click on Administer | Site Configuration | Site Information.
    • In the Default front page, change the value to what was saved for this value earlier in the upgrade.
  13. Put the site back into production:
    • Click on Administer | Site Configuration | Site Maintenance
    • Check Online
    • Click on Save configuration
  14. Review the CiviCRM functionality to ensure that it is working properly.
  15. Re-enable the scripts that you had previously used and saved in the upgrade process:
    
    $ cd /path_to_docroot/sites/all/modules/civicrm/bin
    $ cat /path_to_safe_dir/SavedListOfEnableScripts.txt
    
  16. For each of the script file listed, run a command along the following lines to remove the .txt extension in order to re-enable the script:
    
    $ mv scriptName.php.txt scriptName.php
    
  17. If you are having difficulties, review the troubleshooting suggestions at http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrade+Drupal+Sites+to+3.2#UpgradeDrupalSitesto3.2-UpgradeTroubleshooting. If you are still having trouble, visit the CiviCRM upgrade forum at http://forum.civicrm.org/index.php/board,8.0.html.

After you have finished your upgrade, you should consider whether you need to enable any new components or configure any new CiviCRM permissions.

Moving an installation to a new server

If you are planning to move your website to a new hosting environment or from a development server to a live server, you will need to follow several steps in order to ensure that CiviCRM is configured properly in the new environment. The following content represents the key issues to consider and address when moving your site; a full discussion of steps to move a site can be found online: http://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location.

After transferring your site's files and database to the new location, you must update several files to reflect the changes. CiviCRM references the root directory for your files and the full URL for the site in several locations. Follow these steps:

  1. Modify civicrm.settings.php with the new directory and URL locations. In Drupal installations, this is most often found at /sites/default/civicrm.settings.php. Joomla! maintains two versions of this file, both of which must be updated (and which have slightly different references). You can find them at: /administrator/components/com_civicrm/civicrm.settings.php and /components/com_civicrm/civicrm_settings.php.
  2. Delete the cached template files which will be found at:
    • Drupal:<drupal-root>/sites/default/files/civicrm/templates_c/*
    • Joomla!:<joomla-root>/media/civicrm/templates_c/*
  3. Log in to your site as an administrator and reset the base URL and resource directory configured in your system. For Drupal installations, browse to http://<drupal_site>/index.php?q=civicrm/admin/setting/updateConfigBackend&reset=1. For Joomla! installations, browse to http://<joomla_site>/administrator/index2.php?option=com_civicrm&task=civicrm/admin/setting/updateConfigBackend&reset=1.
  4. Joomla! installations must also manually alter /administrator/components/com_civicrm/civicrm/civicrm.config.php to correctly reference the location of civicrm.settings.php in the administrator folder.
  5. Rebuild the CiviCRM menus, which may include full URLs and must now reflect the new location:
    • Drupal: http://<drupal_site>/index.php?q=civicrm/menu/rebuild&reset=1
    • Joomla!: http://<joomla_site>/administrator/index2.php?option=com_civicrm&task=civicrm/menu/rebuild&reset=1
  6. If any of the resources in your site reference the full URL or file location, you may need to update these (for example, if your Drupal navigation menu has links to profiles).
  7. If you are using override directories (PHP or .tpl), you will need to reset them to reflect the new file location. Go to Administer CiviCRM | Configure | Global Settings | Directories. Also visit the Resource URLs configuration page to confirm that the values are set correctly.

After completing the move, be sure to test the site! Click through CiviCRM and confirm that the pages load as expected, and the URL remains on your new site (if any outdated links exist, it may send you to your old domain or subdirectory).

System maintenance

As with any database system, there will be ongoing maintenance steps that should be performed on a periodic basis. Our focus in this section will be on basic maintenance steps specific to CiviCRM. It is outside the scope of this chapter to address the broader topic of server and MySQL database maintenance. Depending on the size of your database and whether you are using a managed hosting service, you should be aware of basic maintenance steps with your database and hosting environment. Also, we will not address scalability-related issues and maintenance. However, as your system grows, you should be aware of the impact on your MySQL database performance and size.

The most important maintenance step with your system is to keep it updated to the latest revision, and not fall too far behind in major version upgrades. As the steps for doing that have been addressed earlier in this chapter, we won't go into detail here; we repeat it only because of its importance:

  • Revision releases may contain security-related patches which are critical for maintaining a secure and safe database.
  • Revision releases may contain bug-fix patches which are critical for maintaining a stable and fully operational system.
  • Major version releases contain new features and functionality. If the new features are not something you will need or use, you may decide not to upgrade when it is first released. That's fine, and certainly not uncommon. But the core development team will only actively develop and patch the current stable version, which means there may be security or bug issues found in older versions which are not addressed. As a general rule, you should avoid falling too far behind in the upgrade cycle for major revisions. Besides, there's lots of great functionality available in the new releases you'll want to benefit from!

Another important periodic maintenance step is dealing with duplicate contact records that have a sinister way of creeping into your system. This is particularly true if you have multiple forms collecting information from your public website such as event registrations and contribution forms.

Duplicate records usually result from existing contacts completing online forms using an alternative e-mail address or nickname. As a result of the alternate data, the record does not match the existing record, thus causing a duplicate.

Fortunately, CiviCRM has some excellent tools for deduping and merging your database, found under Contacts | Find and Merge Duplicate Contacts. The full range of these tools is detailed later in this book. For the purpose of maintenance considerations, you should schedule periodic deduplication of your entire database. Size and usage of your system will determine how frequently that maintenance should take place. After implementing your system, schedule an initial de-dupe/merge for one month from the go-live date. Depending on how many potential duplicates your dedupe rules uncover, you can schedule the next maintenance review accordingly.

Tip

New functionality for the dedupe/merge tools are currently in development which include performance improvements, whitelist management, and automated processing (running a dedupe rule and auto-merging across your entire database). Follow the CiviCRM blog and release notes for more information.

When covering the initial system configuration, we walked through the creation of cron jobs on your server to trigger automated events and actions. In most cases, these will continue to operate without the need for any intervention or maintenance. However, it is a good idea to periodically check in order to ensure that they are, in fact, running properly and the scripts are completing. While creating the cron job, you may choose to have a log sent to an e-mail address. The log does not contain much by way of detail, but will provide a verification that the script has completed successfully. You should make a habit of periodically checking the configured e-mail to confirm that your scripts are running properly.

These basic maintenance steps should be all you need to keep your system running smoothly.

Developing a backup policy and procedure

No chapter on maintenance would be complete without bringing up the topic of backup policies and procedures.

Regardless of where and how your contact database is being handled, it is pretty safe to say that the data stored in it is critical to the overall success of your organization and should be backed up regularly.

That consideration does not change just because your contact database now resides online. While you may have previously been content relying on the standard backup policies of your hosting provider for your website, the inclusion of CiviCRM as part of your website should now warrant a more robust plan and additional backup mechanisms to ensure your data is preserved and protected.

It is impossible to create a universal backup policy for all organizations. The traffic and usage of the system, nature of the organization, type of data you are maintaining, level of risk exposure, and other factors will all dictate what type of policy you should put in place. If you are uncertain what you should do, consider hiring an outside consultant to do a system and organization analysis for the purpose of developing a backup policy and procedure statement.

However, there are some universal rules and principles to consider:

  • Don't rely on your hosting provider as your sole backup solution: Consider them a backup of the backup—should your own systems fail, they may be able to pull a recent backup and restore it. There are many reasons why you should not rely on them, but it all boils down to a lack of control. You don't have control over how they back up the database and files, when they do it, how frequently they do it, how long they keep the backup sets, how quickly they can provide you the files or restore it for you, or even if they decide to suddenly change their own policies without warning. Bottom line: Let the hosting providers perform their promised backups, but consider them your last line of defense.
  • Create a formal policy and procedure statement: Yes, that's the main thrust of this section, and so it may sound repetitive. However, the point is to be intentional about creating a formal policy. This is important enough to go beyond a casual conversation with someone in the weekly staff meeting.
  • Backups should be automated: Asking Jeff, the accidental in-house IT guy (who also wears six other hats), to run a backup every three days, is not a good policy. You need to know that the backup is happening without the need for human intervention.
  • Periodically check your automated backups and verify their integrity: Nothing hurts worse than relying on, but never testing, your automated backup system. Suddenly, the server goes down and you discover that the .tar package is corrupt. Take the time to periodically unpack the backup, review the files, and actually import the database dump into an empty database to make sure it is complete and functional.
  • In general, the database backup is far more important than the filesystem: Why? All your data, which is likely to be changing and worked on daily, is stored in the database. Your filesystem, primarily the application code, rarely changes. Understand that this is a general statement. If your website and CiviCRM makes regular use of the file upload tools, you will want to ensure those are backed up regularly as well. This statement is not to say that you shouldn't have a policy for backing up the filesystem; we are simply suggesting that you may not need the filesystem backed up as frequently as the database is.
  • Back up to multiple locations: Just as you don't want to rely on your hosting provider as the sole backup solution, you don't want to trust your office intranet or hosting server as the sole repository for backups. Wherever possible, create a system that will maintain regular backups in at least two locations.

Use these basic rules and invest your time and resources to ensure that your data is preserved in the case of accidental loss.

Tip

Both Joomla! and Drupal have several extensions that will generate a periodic database dump, save it to the server, and send the compressed file as an attachment to a configured e-mail address. For smaller CiviCRM implementations, this provides an easy way to automatically generate a backup and send it "off-site" via e-mail. Consider creating a Gmail account (which provides ample storage space) to catch and store the backup. While you should periodically download backups to your local server or other off-site space, this can provide an inexpensive and easy-to-implement backup plan. One caveat to this solution is that you may not be able to e-mail an encrypted version of the database, which means you have a certain level of exposure. This should be considered and factored into your overall policy and procedure. A few available extensions are:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.36