Retrieve image deleted in OMERO from backup

Dear @OMETeam,

in our institute we have an incremental backup of our OMERO database as well as of the storage.

Connected to previous threads ( Caution with copy links in OMERO and Feature request: Add "Trash" folder for deleted images), if a user accidentally deletes an image in OMERO, what would be the best way to retrieve it from backup?

Or, in other words, how to retrieve the exact storage path of a file in OMERO after it was deleted? Are there maybe some log files that mention deletion events?

Thank you for your support and cheers,
Kai

Are you able to restore an old backup of the database so that you can query it with psql? What do you know about the deleted image? Ideally image or fileset ID, but maybe image name, filename, owner, maybe even fairly precisely when it was deleted?

Hi Mark,

thank you for your reply! Just to be sure, the question is hypothetical for the moment. So far no user asked us to restore something, but some expressed their worry and we would like to be ready :slight_smile:

I myself do not know psql, but here the answer is probably “yes, with some help from oher people in our institute” :slight_smile:
Since we have a database backup it should be doable.

I think the most likely is name of the image (or rather some part of the name), name of the dataset in which the image lived, owner, and approximately when it was deleted.

As you’ve probably figured, the key is to be able to construct a query that will find you the image(s) in the database, wherein the originalfile table also captures filesystem paths. The database schema fairly closely follows the structure navigable in the OMERO model object glossary. Information on when images were imported, deleted, who owns, them, etc. is all recorded among the objects and their properties. The usefulness of the “old” version is much about that, after deletion, metadata about the image is no longer retained so, for instance, you can determine from the present database what was deleted when, perhaps by whom, but find out more about those things only from the old copy.

The metadata encoded in the template path used at import time might, if one is lucky, already provide enough to find the image on the backup of OMERO.server’s binary repository.

Of course, recovering and restoring post-import metadata such as users’ annotations is a whole other discussion for which, again, the devil is in the details.

There is also some potential for using the server logs as an extra source of clues but those are less-friendly still and, with luck, unnecessary.

In general I would recommend against believing that you have any capability to restore from backup except during periods when you have recently demostrated such a capability. :smiley: It’s astonishing what one sometimes learns about some relevant previously unadvertised detail of one’s institution’s backup system.

Hi Mark,

Thanks for your answer !

If I understood correctly what you said is : if we have the info about the deleted file (ID etc) found in the backup of the database, then it should be possible to restore an image, is this correct ?

As for everything linked to an image (figures, annotations etc…), is it possible at all to restore/relink to the image ?

Thanks again !

Correct.

All the information about the image and its metadata is somewhere in OMERO.server’s binary repository or among the relational database tables. Much of it is quite navigable. For example, numbers in filepaths can refer to primary keys of table rows and some database tables refer to filepaths. The key is to follow the links, find the related data then restore it in a consistent manner. Basically, possible but not easy, could be fairly time-consuming depending on exactly what’s needed, like following from images to annotations to files to restore attachments. More table joins and whatnot would be needed to try to recover things like ownership information.

Easier for users who are already familiar with working with OMERO metadata from client-side scripts might be to actually restore an “old” version of your OMERO from the backups and run it as a staging server. (Also good to check in advance you can do this and that all seems fine with it when you do.) Then one could write scripts to use the query and update services to “port” the desired metadata from the backup to the current.

Things like figures and shares can be doubly tricky because their related-image information is not encoded by the usual foreign key relationships and the like. But, again, theoretically possible. Also note that if you simply reimport images from backed-up files then they will have new image IDs which a porting script could take into account.

1 Like