Backing up Klocwork data

This article describes backing up and restoring Klocwork data.

All data generated during Klocwork project builds, including the build information stored in the MariaDB database and the defect data stored in Lucene is kept in the projects_root directory, so backing up the entire directory makes sure that this information can be restored if necessary. For more information about the default location and other special considerations, see Projects_root directory.

The Klocwork installation directory contains base checker configuration files, custom checkers and database configuration files that may need to be backed up periodically when they are modified, added or removed.

If you have:

  • customized Klocwork configuration files in the <server_install>/config directory (such as kwfilter.conf and kwmysql.ini), back up this directory as well. Remember to back up these files whenever they are modified.
  • created and deployed custom checkers, back up the <server_install>/plugins directory as well.

As part of an integration build analysis, Klocwork copies any necessary data from the tables directory to the projects_root, so you do not need to back up the tables directory.

Hot, cold, or hybrid backup?

A hot backup means that a backup is performed while the Klocwork Server is running (and users are still logged into the system), while a cold backup involves shutting off the Klocwork Server for a short period to perform the backup.

Both methods have advantages and disadvantages, so we recommend you read the instructions below carefully before deciding which method is best for you. If you choose to do a hot backup, there is potential for data to be lost as users continue to work during the process. Note that hot backup is not officially supported and can lead to corruption. During a cold backup, it is best to inform your users that the servers will be down for a short time to complete the backup.

Important: To ensure data consistency of your backup, you must do a cold backup. A hybrid approach (hot backup followed by a cold backup) will minimize downtime.

Stopping the Klocwork Server (a cold backup) ensures that all in-flight data transactions are complete before the backup is taken and restoration from the backup will be consistent. For that reason, we strongly recommend using the cold backup method, but if you need to minimize downtime, below we list a few options for hot backup methods as well.

Recommendations when performing a backup

  • Back up customized Klocwork configuration files and custom checkers (non-volitile data that is safe to hot-backup). This often includes modified compiler configurations and settings located in <server install>/config and <server install>/plugins, and any custom taxonomies you have created in <server install>/taxonomies (note that these are not used by the live projects root but you may want to back them up anyway). This data can be backed up without stopping the Klocwork servers.

  • Back up the Klocwork project data using one of the methods below. This data is located in your projects root folder and changes frequently as users load builds, cite issues and change settings/configuration. With the exception of using the kwprojcopy method, performing a hot-backup of this data can lead to an inconsistent state when restoring from backup, so extra care must be taken here.

Performing a cold backup

You need to back up any customized Klocwork configuration files from <server_install>/config separately.

To perform a cold backup:
  1. Stop the Klocwork Servers. See Stopping the Klocwork Servers.
  2. Use normal operating system (or backup utility) commands to copy the entire projects_root directory to your desired backup media.
  3. Start the Klocwork Servers. See Starting the Klocwork Servers.

Restoring from a cold backup

Important: Because you are restoring data from the last time you performed a cold backup, you will lose all analyses and transactions performed since the backup. There is no way to automatically reapply transactions to the last backup.

To restore from a cold backup:
  1. Stop any running Klocwork Servers. See Stopping the Klocwork Servers.
  2. If the entire installation was corrupted and reinstalled, and if you had backed up any configuration files as part of the preparation phase, copy them back to the newly installed <server_install>/config directory.
  3. Delete the entire content of the (corrupted) projects_root directory.
  4. Restore the entire projects_root from backup media to the projects_root location.
  5. Start the Klocwork Servers on the restored projects_root. See Starting the Klocwork Servers.

Performing a hot backup

To perform a backup while the your servers are still running, these are the methods we currently recommend:

1. Using kwprojcopy

Use kwprojcopy to incrementally back up each project. You can then restore your data at a later date by using kwprojcopy's import function. While kwprojcopy is running, it locks projects and collects data required for a project backup.

Using kwprojcopy requires no downtime but only backs up project specific data and not global data (for example, reports definitions).

2. Rsync Double Backup

Rsync is a tool you can use to incrementally copy files at the binary level. If you do a full backup, then the next rsync will only copy the changed files; thus reducing the time taken for incremental backups.

You can use Rsync to minimize downtime by doing the initial Rsync with the servers up, and then run a second rsync with servers down, to update.

You can use this method to reduce the Klocwork Server down time when doing a full projects_root backup:

  1. Run "rsync -a projects_root projects_root_backup" on the live Klocwork projects_root with the Klocwork Server is running.
  2. Stop the Klocwork Server.
  3. Run "rsync -a --delete projects_root projects_root_backup" to copy the changed files (which likely is a smaller amount of files and should take less time to complete).
  4. Start the Klocwork Server.

To restore from the rsync backup, you need to stop the Klocwork Server and replace your current projects_root folder with the 'projects_root_backup' you created. Restart the Klocwork Server to complete the restoration.

3. Back up an entire Virtual Machine

You can also use Virtual Machine (VM) backups for a faster backup while your servers are down. This may be a viable option, but the amount of time it takes you to create a snapshot in different VM architectures needs to be investigated before you perform this method.

  1. Stop the Klocwork Server.
  2. Back up the VM image according to your requirements and procedures.
  3. Start the Klocwork Server.

To complete the restoration from the backup, you need to stop the Klocwork Server and replace your current VM image and/or projects_root folder. Restart the Klocwork Server to complete the restoration.