I ran into the situation recently where I thought I had some files in a directory, but when I went there, I found nothing.
Is it possible to have nextcloud synced to a mac mini, which uses time machine backup to keep a backup of nextcloud? That way I could see if those files were in that directory on an earlier date.
It should work, at least for classic synchronization folders. Check the directories are included after the first backup and it should be fine. In case of the file provider extension: I currently do not know how “dataless” files (not downloaded but listed) are handled or whether file providers are excluded from backups completely.
Right now, I do not have a Time Machine set up because I manage my work environment(s) as discardable, hence I cannot verify that myself.
I am not sure if this would mess something up.
Time Machine only reads the source volume. If I recall correctly and nothing changed, it cannot mess up anything in regard to Nextcloud. It reads the files in the synchronized folder and only copies them to the Time Machine volume.
About Nextcloud Version Control
Please note that Nextcloud has support for file versions. However, as you explicitly mentioned backups, that feature does not replace actual backups.
About Nextcloud All-in-One
If you are using a Nextcloud All-in-One deployment (my favorite choice), then you can conveniently use the integrated Borg backup system.
You rely a bit that everything is synced correctly and you don’t use the virtual file sync.
I’d rather try to make a server backup that allows you to go back in time. Either snapshots at different times, or just on the difference (something similar like rsnapshotd). But there are endless backup solutions that do similar things (rsync family, borg, restic). That is more suited to backup the server, restore things for the server (single files, but also the whole server if something happens).