Check if you have a NextcloudPi backup, if you do you can restore it and get a working setup back in a few minutes, for me it worked twice; just be sure to secure your Nextcloud shared data beforehand, because it could be replaced with an empty directory if you just restore the ncp backup.
You can follow the steps I wrote in this answer.
Again, please make sure to copy/move your Nextcloud data somewhere safe BEFORE restoring your ncp backup.