Trying to bulk undelete directly on server

Support intro

Nextcloud version (eg, 20.0.5): 20.0.12
Operating system and version (eg, Ubuntu 20.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.4): 3.3.29

The issue you are facing:

A user deleted a lot of files. We would like to restore them without using the web UI. The initial plan was to move them in the file system, use files:scan then delete the oc_files_trash rows for the files.

However, this creates a bunch of new files and breaks links and history.

Is there some PHP internal code that can be called to do this, given a list of file IDs or paths? Some other way? Or can we do the above, then update the IDs in oc_files_cache (which seems quite dangerous).

Any suggestions welcome!

I’m not aware of such functionality as of now so I added this 2 issues shortly:

please like and keep checking them for the solution. Short term I think best is to let the user recover files using UI. I had to restore hundreds of files in the past (deleted by the sync within short period) and it was good enough - maybe 5 min/100 Files