WE had some sort of corruption on our CiviCRM db and somehow lost data in different fields

One of these was a custom field containing uploaded files

THese files are still listed in the civicrm_file table and the file ids are also associated with the civicrm entity in civicrm_entity_file.

BUt they do not show up in the contact profile.

I tried adding a new file to a contact and this shows up. I can't see any difference between the record for the new file and the one for the old file.

Any ideas how to restore these? there are 756 files, so it would be a lot of work to manually do it.

  • If you have logging on then you might want to look at the log_ tables to see if there is some information on who/when your data was lost
    – petednz - fuzion
    Commented Apr 8, 2018 at 19:52

1 Answer 1


If you say the file record is correctly present in civicrm_file and civicrm_entity_file table, then only thing which is missing seems to be the entry for it in custom value table. To verify this yourself -

  • Check the custom value table name mentioned in civicrm_entity_file (entity_table column).
  • Open the above custom table and make sure it contains the mapping of civicrm_file id and entity_id(contact id)
  • YES! That is where the problem is. THe data for all these files is missing. It seems I can import the entity_id and File_id into the custom table, putting the file_id into the custom field column. I'll try it and see. Thank YOU!! Commented Apr 8, 2018 at 7:59
  • 4
    Success! I created a CSV file with just the entity_id and file_id and imported it with phpmyadmin. Voila, they are all back! Commented Apr 8, 2018 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.