Need help fixing corrupt files on the server

Nextcloud version : 19.0.1
Operating system and version : Ubuntu 20.04.01 LTS
Apache version : 2.4.41
PHP version : 7.4

Through no fault of Nextcloud, some user files have gotten corrupt on the server. How can I get proper copies of the files automatically recopied to the server? Could it be as simple as deleting the files from the underlying filesystem and Nextcloud will request the files be uploaded again?

Please be more specific. Are you asking the questions on behalf of yourself, or on behalf of the other persons with access to your installation?

As we may have the same issue, please provide more information on your topic by updating your post. At least with online forums, I have found that it really helps when someone provides me a template to fill in the needed details. Although my installation at times corrupts my own files, with and without resulting from any configuration changes, I have identified and posted several cases where file corruption may be the result of user- or administrator-related activities here, https://help.nextcloud.com/u/rhua/activity.

At least one person highly recommends this topic as a template that could help you be more specific about your installation, despite the fact that the title of the example could be improved:

If you have not yet done so, you may be interested in replying or even linking to the topic, Files could not load after being restored from trash, to help other users on the forum easily identify the similarities between our problems.

I’m the admin of the system in question. I’m sure that it was not Nextcloud or its processes that caused the corruption. The system is a local VM using local storage. My data repository is a zfs mirror that got borked and reported permanent errors on 3 files. There’s no way that Nextcloud could cause incorrect zfs checksums to be written for any data.

I was trying to discover if there was a mechanism within Nextcloud to request that the files be re-uploaded. If not, I’ll manually delete the files out of the filesystem and replace them with copies garnered from the original source.

For the future, I’m putting processes in place to snapshot and mirror the data to another system.

How did you come to know that Nextcloud, or a process related to its setup, could not be a cause of file corruption?

If this quote is relevant in your case, it may help you isolate another cause of your issue:

To help those using the forum, please do let us know of your findings. Although some of my files became corrupted without any user intervention, there could be different causes to our issues.

How do you plan to snapshot your installation and mirror the data to another system?

How did you come to know that Nextcloud, or a process related to its setup, could not be a cause of file corruption?

I’d recommend that you look into the ZFS filesystem (though it’s much more than just a filesystem).

ZFS, when properly set up owns from the filesystem down to the bare drives. When ZFS writes data, it checksums/hashes that data and also stores the checksum/hash. When it reads that data back it also reads back the checksum/hash and checks it against the data. This is to be able to correct for drive-level uncorrectable errors.

In my case, I had ZFS mirroring my data to two devices, however one of the mirrors had gone offline without my noticing (notification is now in place) and continued to run. When I ran a scrub/resilver on the ZFS volume, ZFS had some data which was not in compliance with the checksums. Since ZFS owns from the devices up and also creates the checksums, I can pretty much rule out anything above the filesystem level, i.e. Nextcloud, unless for whatever reason they’re somehow attempting to access the raw disks.

To correct the errors that I found, fortunately I still had access to the original files on the device they were ingested into Nextcloud from. I manually copied those files into the correct directory, replacing the corrupt files.

How do you plan to snapshot your installation and mirror the data to another system?

Two very nice features built into ZFS are snapshotting and replication. Once I recovered the Nextcloud data and had everything proper again, I set up ZFS to snapshot the Nextcloud data on a schedule and replicate those snapshots to a FreeNAS box that I have running.