File integrity checking

ResourceSpace includes a tool to verify the file integrity of primary resource files, allowing you to be notified should any corruption occur and take remedial action as necessary.

Configuring the file integrity check

To configure the system to check file integrity you need to have the following configured

  • Full file checksums (set the following options)
    $file_checksums     = true;
    $file_checksums_50k = false;
    $file_checksums_offline = false;*
    * If $file_checksums_offline is true then /pages/tools/update_checksums.php must be run regularly

Running the file integrity check

Resource integrity is validated by checking the current file checksum against those stored in the database. This can be done in two ways:

  1. Using cron_copy_hitcount.php (see setting up scheduled tasks/cron

    Configure the following setting


    This defines a time window in which checksums will be verified by the cron script . The integrity check script will be started whenever the cron script is run in this window and will check all primary resource files that have not been verified in the last 24 hours, or those that have never been verified. If the cron job is run in this window then it will carry on validating checksums until the window ends. 

    Examples: -

    $file_integrity_verify_window = [22,6]; // This will run between 10PM and 6AM (the first hour is later than second so time must be after the first OR before the second)

    $file_integrity_verify_window = [18,0]; // Between 6PM and 12AM (midnight)

    $file_integrity_verify_window = [0,0]; // Off by default

  2.  Alternatively, set up a new cron task/scheduled task to run the following script* 


    Script options
    --lastchecked [number of days] Only check resources not validated in the last X days
    --maxresources [number] Maximum number of resources to check

    *This is only available from version 10.4.

    The script can be run regularly to validate the integrity of resource files outside of the configured file_integrity_verify_window. This should be run with a low priority similarly to the update checksums scripts.

When the script has finished, ResourceSpace will send a notification message to the system administrators if any resources have failed, who can then take action as necessary to resolve the situation e.g. restore files from backups.

* This message will only be sent to system administrators that have the option to receive system notifications set in their user preferences and will not be sent more than once a day.

Search for resources with file integrity failures

Running the special search '!integrityfail' will show you all resources that have failed the last integrity check.

The stored checksums can be downloaded and viewed by choosing the 'CSV export - metadata' option for any set of search results and selecting the 'Include data from all accessible fields' option. This can be useful for large migrations to ensure that file integrity has been maintained throughout. All that is required is to compare the ResourceSpace generated checksums with those generated from the original files using a third party checksum tool or script.