Versions: restore a list of files to the previous version

i a trying to find a solution to restore approximately 1600 pdf files to the previous last version. All of these pdf files are 0 byte. My suspicion is that something went wrong with OCR Workflow. But i did not investigating this further so far.


find . -type f -iname '*.pdf' -empty > list.txt

i was able to get all of these files. Is there a way to restore them with an occ command or something else? Any other ideas are also welcome.

I would recommend to copy the files to the desired directory and then use the “occ files:scan ...” command to update the directory index of the destination directory.

Thanks j-ed for pointing me in the right direction!
The situation is likely related to a bug in Workflow OCR.
With a script i could overwrite the files from “user/files_versions/…” to “user/files/…” and then did a “occ files:scan user”.
The nextcloud webpage shows the reverted PDF files now correctly. However, my Linux desktop client 3.0.2 (Ubuntu) is not updating. Cron jobs are running fine…

1 Like

To solve this i had to:

  1. Use a script to detect all zero byte PDFs in ‘user/files/’ directory, cross-check if an older version is available in ‘user/files_versions/’ directory and then overwrite the empty PDF with the newest version
  2. run sudo -u www-data php occ files:scan --all
    This was only updating PDF files on Nextcloud website
  3. uncheck → apply → check all related folders in desktop client
    Why? I don’t know. But i got all PDFs back on my computer.

Holy guacamole! :avocado:

in the post below I described the way to find the files with invalid mtime from DB. Size attribute exists in the filecache database table as well. you could start with the same approach…