../webwork2/bin/remove_stale_images
can be used to accomplish this task. There are instructions at the top of the script. Another trick which will save storage space on backup is to place the tmp directory outside of the main webwork heierarchy. For example one can change the entry in the webwork2/conf/global.conf file:
# Location of web-accessible temporary files, such as equation images. #$webworkDirs{htdocs_temp} = "$webworkDirs{htdocs}/tmp"; #$webworkURLs{htdocs_temp} = "$webworkURLs{htdocs}/tmp"; $webworkDirs{htdocs_temp} = "/ww/htdocs/tmp"; $webworkURLs{htdocs_temp} = "/tmp";which places the tmp directory immediately under the main webserver directory where it is not backed up. As far as I know everything in the tmp directory can be recreated so it does not need to be backed up, the only penalty for deleting its contents is a slight performance hit while the cached equations and .gif files are being recreated.