Cleaning Up Old Attachment Files

As part of Cassandra deprecation, the migration script copies and renames attachment files to the new naming convention, but it does not delete the old files. To help you complete the cleanup, we provide an additional script that allows you to safely remove these outdated files.

Key Usage Information

Prerequisites

  • Ensure the Cassandra deprecation migration has been completed first.
  • PHP command line interface is required.
  • Read/write permissions are needed on both the attachments directory and the script directory.
  • Back up your attachments directory before proceeding.
  • Run in dry-run mode to preview what will be deleted:
    php remove_cassandra_attachments.php /path/to/attachments --dry-run
  • Review the generated file cassandra_files_to_delete.txt, which lists the files that would be automatically deleted by the tool.
  • Once confirmed, run the actual cleanup:
    php remove_cassandra_attachments.php /path/to/attachments

Quick start with the script

You can execute the following command to delete all old files (based on filename checks):

php remove_cassandra_attachments.php /path/to/attachments

If you prefer to first inspect which files will be deleted, you can run the script in dry-run mode. This will generate a text file listing the files that would be removed:

php remove_cassandra_attachments.php /path/to/attachments --dry-run 

  Full script on Github

Get the latest version of the cleanup script on GitHub.

Was this article helpful?
3 out of 6 found this helpful