The first error is in setup/nextclound.sh, where echo "ALTER TABLE oc_flow_operations ADD COLUMN entity VARCHAR;" | sqlite3 $STORAGE_ROOT/owncloud/owncloud.db
fails with Error: near line 1: duplicate column name: entity
OK, maybe I ran the setup twice, and you can only add a column so many times (*). So I commented out that line, and here’s what happened next:
`Upgrading to Nextcloud version 18.0.10
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [14] unable to open database file in /usr/local/lib/owncloud/lib/private/DB/Connection.php:68
Stack trace: #0 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1040): OC\DB\Connection->connect()
[stack entries #1 through #47 omitted]`
The database file referenced in setup/nextcloud.sh does exist, and sqlite3 /home/user-data/owncloud/owncloud.db opens the database just fine (and btw, the .schema command shows that the ALTER TABLE worked and the new column is indeed in place). I’m not sure what db it’s trying to open that isn’t. Any suggestions on how to get past this?
Commenting out the source nextcloud.sh line from setup/start.sh allowed me to finish running the setup, reboot, and try again. I also did an apt-get upgrade before all this.
(*) Maybe it’s worth adding a clause that if sqlite3 $STORAGE_ROOT/owncloud/owncloud.db ".schema" | grep 'oc_flow_operations.*entity'
returns 0, skip the ALTER TABLE step?
I didn’t change that line (or anything else besides the duplicated alter table). I believe the script updates incrementally, from 17 to 18 to 19 to 20. If I’m at 17, do you think I could skip the incremental steps and jump to 20?
My current problem is that the upgrade failed and I can’t access my calendar or contacts. When I go to the nextcloud calendar page, I get The server encountered an internal error and was unable to complete your request.
This is surely due to the failed install—it worked before I started. The error message during the install is:
Upgrading to Nextcloud version 18.0.10
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [14] unable to open database file in /usr/local/lib/owncloud/lib/private/DB/Connection.php:68
Stack trace:
#0 /usr/local/lib/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1040): OC\DB\Connection->connect()
I’m confident that the error is from line 85 of setup/nextcloud.sh,
I did complete the update of everything but nextcloud, using the setup script I downloaded today. So the version I’m upgrading to is whatever we’re up to right now.
Given that the update completed, how can I find the previous version I’d been using? I’m not seeing it in the logs or admin panel. It’s been several months since the last update, though.
I looks like the first MiaB version to include Nextcloud 20 was version .51 in October 2020. What is the version number you have right now? What command did you use to install it?
It’s entirely possible that it’s been over a year since I upgraded… It was early in the pandemic.
I don’t recall ever doing nextcloud setup using anything other than the mailinabox setup tool. As you can see from this thread, I wouldn’t know how.
Here’s what’s in /usr/local/lib/owncloud/version.php right now:
I don’t have experience with modifying Nextcloud. I believe for you to do that you had to unlock admin access, or something of that nature, and I am unable to tell you whether that does or does not impact your current upgrade problem using the normal MiaB upgrade process.
OK, thanks for chatting about this. If I have time in the next few days, I’ll try to see if I can research that unable to open database error. I’ve restored /home/user-data from pre-upgrade backups, so it must be there somewhere…
If you dare, you might want to try to follow the nextcloud install script manually. As you already mentioned, the error probably occurs with the line sudo -u www-data php /usr/local/lib/owncloud/occ upgrade . To have it log verbosely sudo -u www-data php /usr/local/lib/owncloud/occ upgrade -v
Also, check the access rights of the database. Is it owned by the www-data user?
Finally, Nextcloud upgrade doc notes the command sudo -u www-data php occ maintenance:repair. But I’m not sure exactly what it does, and have never used it myself.
Even the occ upgrade gave me errors about not being able to open the db. In the end, I did just cut/paste from the install script to do a reinstall. The fresh install worked just fine.
Thanks, @openletter and @KiekerJan, for your suggestions.
Maybe it’s moot now, but I’m still a little confounded about how the install script as sudo’d root could modify the db via the alter table discussed above, but owncloud’s occ couldn’t connect to it even to answer basic read-only questions. I never did check the ownership of /home/user-data/owncloud/owncloud.db; a good suggestion that I didn’t think of before overwriting everything. Or, maybe there’s another db being referenced by occ?