Remove corrupted files from storage

Infos:

  • Used Zammad version: 3.1.0
  • Used Zammad installation source: tar-ball
  • Operating system: Debian Stretch
  • Browser + version: Firefox 70

Unfortunately we lost a few files from the disk file storage, and we won’t be able to recover them. Is there a relatively clean way to remove the files from zammad without breaking everything?

There is, even though this is absolutely on your own risk (aka. backup!) and we do not take any responsibility for running this script:

      file_ids = Store::File.all.pluck(:id)
      file_ids.each do |item_id|
        item = Store::File.find(item_id)
        begin
          content = item.content
        rescue => e
          # file lost, why?
          # only way to fix is to delete references from DB
          Rails.logger.error "the following file is lost: #{e}"


          # uncomment the next to delete references
          #Store.where(store_file_id: item.id).delete_all
          #item.delete
        end
      end

I completely understand.

As to why we have to do this. Unfortunately the Zammad installation was removed and reinstalled due to an issue with the server setup. When the Zammad installation was removed, no backup of the disk store had been created and the files in questions where imported just in between the general disk backups. Therefore, no backup had been made yet. Yes very bad timing.

I will give this a shot.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.