How can I further use a running nextcloudpi instance but start with new empty data directory and database?

Hello everyone
I am not sure if this is the right topic, because my nextcloud is already set. But I do not find a topic where USB drive problems are under discussion. So this is the topic that fits best in my opinion.

I have a question that should be easy to answer, but I cannot find a solution:
How can I further use a running nextcloudpi instance but start with new empty data directory and database?
(I would like to avoid re-installing Nextcloudpi so that I don’t have to configure everything anew.)

Background information:
I use ncp 1.53.1.
I want to use a new (bigger) USB-drive as datastorrage at raspi, without resetting the nextcloudpi installed on the SD-Card.
The USB-drive is formated as a BTRFS partition and listed: /media/silverStick
The problem is, that nextcloudpi wants me to move data directory and I have to chose the Data directory path. But the USB-drive is empty and so it is not possible. Prompting the ncdata-directory (and the database-directory) that do not exist as destination does not work.
→ data directory /media/silverStick/ncdata/data not found

So I tried to create a new directory with the name “ncdata” but that does not help.
–>0 drwxr-xr-x 1 root root 0 Feb 16 10:58 ncdata
even when I change owner (chown) root to www-data

The Question is: How can I create the ncdata- and the ncdatabase-directory on the new formated usb-drive properly?

Try creating a btrfs sub-volume first with:

sudo btrfs sub-volume create /media/silverStick/ncdata

then give ownership to www-data and proceed moving datadir using ncp tool

If you want to use UUID to mount drive check howto here

Thanks OliverV
that worked very well so far and was the first part of the solution (after a litle correction):

sudo btrfs subvolume create /media/silverStick/ncdata

After I changed the owner…

sudo chown www-data ncdata  

… I had to create a second subfolder “data” the same way.
Then the process of moving datadir using ncp tool worked fine for me. :smiley:

But that was just the first part of the problem. :face_with_monocle:
It seems like the second part can not be solved this way…

Because after this success I tried the same solution for the database and this does not work. :frowning:

An unhandled exception has been thrown: Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:140

The database should be created here from scratch, and I do not understand, how to tell the nextcloudpi to do this?

You can use

nc-database Move your database to a new location, like a USB drive

or use

nc-init (Re)initiate Nextcloud to a clean configuration

It start a fresh clean database.

Both From terminal ncp-config>CONFIG>
Or via ncp-web:4443

Make backups before proceeding :wink:
Can search and find more info at NCP-Documentation

Thank you Oliver.
This function/sript was new for me.
I tried my best, but it seems like it is not working the way it should.
After a permission problem that I was able to solve by changing the owner of the directory to mysql, the NCP is running the init-script a little further. But in the end it throws an exception:

[ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘mysql.db’ doesn’t exist

This sounds funny to me, because isn’t the idea of this script to create the database with the neccessary tables?

Hm, I am a little surprised. I really thought, that this problem could be solved by some cracks out there pretty easily. But it seems to be more complicated and challenging than it initially looked.
For me it looks like a bug. All in all I it looks to me like some of nextcloudpi-scripts are still quite buggy. Could it be that the program still has some teething troubles and is simply not yet fully developed?

Is nobody out there who has already done a memory expansion and also faced the problem that the database had to be set up on the stick?

Or could it be that this bug was only integrated in one of the last updates?