Did the logs (nextcloud.log, mariadb.log, messages) provided any hint about the failure?
Have you checked if database tables need to be repaired?
Is there any previous backup that could be of use?
Other than inferring it from the table names and contents I’ve no clue. But there are some users who fiddled with nextcloud database internals (Migrating Nextcloud data? - #13 by danb35)
Yes, usually works out of the box.