Upgrading NC to a recent version fails

Hi guys,

I have really bad troubles upgrading my Nextcloud instance. My provider messed up the PHP config recently so my Nextcloud stopped working suddenly. I had a really hard time to make sure it’s not my own fault and convince the provider of this. Finally i got my NC 16.0.9 to work again. I found out that version 16 is not longer supported so I tried to upgrade my Nextcloud to a recent version afterwards.

First I installed the latest build of 16 (16.0.11). Using the web updater didn’t work. I had to manually replace the files and could use the web updater afterwards to update the database.

That having done i proceeded to install the latest version 17 (17.0.8). The web updater downloaded the files and swapped them. I would have expected the page where I am prompted to upgrade the database. Instead I received a “HTTP ERROR 500”.

Thats when I started researching again but had no luck so far. Some users stated that they had a similar problem using the web updater and they then used the occ command. So I tried that as well. Unfortunately I can’t get it to work. Bash uses PHP 5 something by default so i have to pick the right PHP version. No matter what i want to execute with occ it always tells me it ‘cannot create “data” directory’. This is what it looks like:

bash-4.3$ /opt/plesk/php/7.1/bin/php occ upgrade
The current PHP memory limit is below the recommended value of 512MB.
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/17/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /httpdocs/nc.***.de/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /httpdocs/nc.***.de/nextcloud/console.php(96): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /httpdocs/nc.***.de/nextcloud/occ(11): require_once('/httpdocs/nc.**...')

My data directory is not in the nextcloud root dir. It is beside the nextcloud directory.
Nextcloud root: /httpdocs/nc..de/nextcloud/
Nextcloud data: /httpdocs/nc.
.de/data/

The data dir is correctly configured in the config file. It did work in nc16. The line in the config file is:
‘datadirectory’ => ‘/var/www/vhosts/.de/httpdocs/nc..de/data’,

As I only have limited access to the console I only have access to files below /var/www/vhosts/***.de/. Unfortunately my provider mounted this path as my root. So when I try to change directory to the path given in the config file I get a “no such file or directory”.

The data directory has the Permission 770 having the www-user as owner and the www-group.

I tried my luck swapping the PHP versions to get the web updater working but even that didn’t work. (I tried PHP 7.1.33, 7.2.32, 7.3.20 and 7.4.8.)

Does anyone have an Idea how to fix this? I really hope so otherwise I’m stuck to nc16 which I think I have to shutdown due to the high security risks. So I keep my fingers crossed.

If you need any details that I didn’t provide feel free to ask. As my provider only gives limited access I unfortunately don’t have all the details.

[/details]

Nextcloud version: Database 16.0.11, Files 17.0.8
Operating system and version: unknown
Apache or nginx version (eg, Apache 2.4.25): unknown
PHP version (eg, 7.1): 7.1.33

Is this the first time you’ve seen this error? : Y

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocrhvfecjj5q',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.***.de',
    1 => 'nc.***.de',
	2 => 'localhost',
	3 => 'nginx',
  ),
  'datadirectory' => '/var/www/vhosts/***.de/httpdocs/nc.***.de/data',
  'overwrite.cli.url' => 'http://nc.***.de',
  'dbtype' => 'mysql',
  'version' => '16.0.11.1',
  'dbname' => '***_nextcloud',
  'dbhost' => '*.*.*.*:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '***',
  'dbpassword' => '***',
  'installed' => true,
  'forcessl' => true,
  'forceSSLforSubdomains' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'mail_from_address' => '***',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => '***.de',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'nextcloud@***.de',
  'mail_smtppassword' => '***',
  'mail_smtphost' => '***.***.com',
  'mail_smtpport' => '25',
  'updater.secret' => '***',
);

The output of your Apache/nginx/system log in /var/log/____: no access

For the memory limit of the cli-php, I don’t know if you can change this anywhere.

When you are on the console, which user are you (whoami)? It should be the www-user to match the permissions of the php process run by the webserver. If that isn’t the case, you can use sudo (if possible).

Unfortunately, it depends a lot on what you can do at this host. One way that works, but which is very complicated, is that you migrate the whole setup in a virtual machine at your home. Do the upgrade there and then migrate it back to the shared system. In theory, the user’s data is not touched, perhaps there are ways to avoid to migrate all the data. Upgrade usually change the database and the code files, the data-files are in general not altered.

The memory limit is fixed for me. As i have only limited access and also a limited bash the only possible way to change things is in plesk. But the option is fixed there as well. So I will have to live with that.

whoami doesn’t work in my environment. Please don’t ask me, why they removed that command. It doesn’t make any sense. I asked the staff and they told me that the www-user is the user I’m logged in with and the group I used is the correct group. I’m not into linux that much so I can’t proof if that is correct or not. As the error messages are more than 99% correct and wouldn’t rule the option out that it is not correct.

If no one has any other idea I’ll have to setup a local box, transfer the Nextcloud instance to a local box, upgrade it and transfer it back to the webserver… I hope I can spare this part somehow. :slightly_frowning_face: