Need help rebuilding my nexcloud

Through a series of improbable events, I managed to nuke my nexcloud setup.

What I have left is:

  • The full virtual host nextcloud folder (the actual install, with config files, etc.)
  • The nextcloud data directory on the server
  • Several copies of the data on various computers fitted with the nextcloud client

What I am missing is the database.

Additional details:
I only had 1 main user on nextcloud but I was sharing a couple of folders with 2 other users (so 3 users total, only one with actual files.

What would you guys recommend as the best option to rebuild my setup? I imagine starting fresh and copying the files from one of the client computer would be the easiest thing to do, correct?


You could build the fresh server and setup the same users, then restore the users data directories, and then run an occ scan to rebuild the database.
sudo -u www-data php occ files:scan --all
or for individual users;
sudo -u www-data php occ file:scan -v

So basically the database is lost/broken and no working backup of it is there? I recommend using ownBackup to avoid this, which stores a series of database backups inside the data directory.

Yes in this case just using old nextcloud directory and data directory and do files:scan --all would rebuild the files database, but shares, several settings, contacts and calendars in case will be lost. Of course the letter ones could be restored by the contacts/calendar clients. Just be sure to export them first, in case the empty server calendar/contacts databases will override the full ones on client side.

In case you use the old config.php, you need to set “installed => false” to be able to reinstall and rebuild the skeleton user database.

Thanks for the tips everybody…

I ended up rebuilding from scratch. It will be trivial (if somewhat network intensive) to recopy the files from one of the client so I figured this would be the cleanest way to do it.

And yes, I will not be caught ever again without a relatively recent sql dump!


This saved my butt when my local MySql setup went pear shaped, following MySQL’s instructions for completely removing the installation included a delete I should have (in hind sight) looked at closer before executing, since it ended up deleting the dump file too. I took a backup of my config file, reinstalled NextCloud, reset up my users (FYI case matters when doing that, at least on linux), and have run the re-scan. Now I just need to add my plugin’s back, but this was a huge life saver with over 1.5 TB in my NextCloud.:grin: