Nextcloud Upgrade from 13.x.x to 14.x.x

Errors & Solutions When Upgrading from Nextcloud 13.x.x to 14.x.x

Issue/Error 1:

A. After updating you can not login and are receiving a ‘wrong password' message. B. When you try to reset the user password via the cli using occ and see a message stating that the ‘User does not exit' (but you can see in the ‘oc_users' table of the db that the user(s) do exist with hashed passwords).

Solution 1:

Optimize the database (substituting ‘dbname' for the Nextcloud database name):

$ mysqlcheck -u root -p -o dbname

output:

nextcloud.oc_accounts
note     : Table does not support optimize, doing recreate + analyze instead
status   : OK
nextcloud.oc_activity
note     : Table does not support optimize, doing recreate + analyze instead
status   : OK
... ...

Each table will be checked and ‘optimized' (recreated and analyzed) and when finished you should now be able to login.

Issue/Error 2:

A. In Settings > Overview, inside the ‘Security & setup warnings' section you get this message:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

    Missing index "share_with_index" in table "oc_share".
    Missing index "parent_index" in table "oc_share".
    Missing index "fs_mtime" in table "oc_filecache".

Solution 2:

Add the missing tables by running this command (make sure the path to the Nextcloud directory is correct):

$ sudo -u www-data php /var/www/html/nextcloud/occ db:add-missing-indices

Issue/Error 3:

A. In Settings > Overview, inside the ‘Security & setup warnings' section you get a message similar to this:

Last background job execution ran 1 hour ago. Something seems wrong. Check the background job settings

Solution 3:

Run the cron manually (make sure the path to the Nextcloud directory is correct):

$ sudo -u www-data php -f /var/www/html/nextcloud/cron.php

Issue/Error 4:

A. In Settings > Overview, inside the ‘Security & setup warnings' section you get a message similar to this:

The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information.

Solution 4:

If using nginx:
https://docs.nextcloud.com/server/14/admin_manual/installation/nginx.html

Add the code below to the line in the nginx configuration just under ‘add_header X-Permitted-Cross-Domain-Policies none;':

add_header Referrer-Policy no-referrer;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

also add the last line of code below at the end of the code block that starts with:

location ~* \.(?:css|js)$ {
...
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;

Note that there are a few more differences in the Nextcloud 14 nginx configuration that may or may not have any noticeable effect.

Issue/Error 5:

https://github.com/nextcloud/server/issues/10954
https://github.com/nextcloud/server/issues/10954
https://help.nextcloud.com/t/14-0-0-0-rc1-error-after-upgrading/35709/2
https://docs.nextcloud.com/server/14/admin_manual/configuration_server/occ_command.html

The web based updater fails with a message similar to:

This Nextcloud instance is currently in maintenance mode, which may take a while.

This page will refresh itself when the Nextcloud instance is available again.

Contact your system administrator if this message persists or appeared unexpectedly.

Thank you for your patience.

You will have to update using the command line.

1. Run the updater from the command line (replace with the correct directory):

$ cd /var/www/html/nextclouod/updater
$ sudo -u www-data php updater.phar

When following the prompts you see an error that the update fails, similar to below:

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n] y
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
Set log level to debug
Updating database schema
Updated database
Checking for update of app activity in appstore
An unhandled exception has been thrown:
Error: Call to undefined method GuzzleHttp\Client::request() in /var/www/cloud.imarkethost.co.uk/html/lib/private/Http/Client/Client.php:161
Stack trace:
#0 /var/www/cloud.imarkethost.co.uk/html/lib/private/App/AppStore/Fetcher/Fetcher.php(106): OC\Http\Client\Client->get('https://apps.ne...', Array)
#1 /var/www/cloud.imarkethost.co.uk/html/lib/private/App/AppStore/Fetcher/AppFetcher.php(80): OC\App\AppStore\Fetcher\Fetcher->fetch('', '')
#2 /var/www/cloud.imarkethost.co.uk/html/lib/private/App/AppStore/Fetcher/Fetcher.php(170): OC\App\AppStore\Fetcher\AppFetcher->fetch('', '')
#3 /var/www/cloud.imarkethost.co.uk/html/lib/private/Installer.php(385): OC\App\AppStore\Fetcher\Fetcher->get()
#4 /var/www/cloud.imarkethost.co.uk/html/lib/private/Updater.php(445): OC\Installer->isUpdateAvailable('activity')
#5 /var/www/cloud.imarkethost.co.uk/html/lib/private/Updater.php(256): OC\Updater->upgradeAppStoreApps(Array)
#6 /var/www/cloud.imarkethost.co.uk/html/lib/private/Updater.php(126): OC\Updater->doUpgrade('14.0.1.1', '13.0.6.1')
#7 /var/www/cloud.imarkethost.co.uk/html/core/Command/Upgrade.php(262): OC\Updater->upgrade()
#8 /var/www/cloud.imarkethost.co.uk/html/3rdparty/symfony/console/Command/Command.php(251): OC\Core\Command\Upgrade->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/cloud.imarkethost.co.uk/html/3rdparty/symfony/console/Application.php(946): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/cloud.imarkethost.co.uk/html/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Upgrade), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/cloud.imarkethost.co.uk/html/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/cloud.imarkethost.co.uk/html/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/cloud.imarkethost.co.uk/html/console.php(96): OC\Console\Application->run()
#14 /var/www/cloud.imarkethost.co.uk/html/occ(11): require_once('/var/www/cloud....')
#15 {main}
Keep maintenance mode active? [y/N] y

Solution 5:

We must disable Nextcloud apps that are causing this problem. You can list all apps in Nextcloud with this command (inside the root Nextcloud directory – one folder up from where you may be now if you are in the directory /var/www/html/nextclouod/updater):

$ sudo -u www-data php occ app:list

You can see all of the enabled and disabled apps. I disabled both the ‘activity' and ‘files_external_gdrive' apps (you may also need to disable bookmarks):

$ sudo -u www-data php ./occ app:disable activity
$ sudo -u www-data php ./occ app:disable files_external_gdrive

Then checked to see that the apps are disabled:

$ sudo -u www-data php occ app:list

You can also check the status of Nextcloud:

$ sudo -u www-data php occ status

Then re-run the upgrader script (from the current directory):

$ sudo -u www-data php updater/updater.phar

and the update was successful. When prompted to ‘Keep maintenance mode active?', type ‘n'. Then enable the ‘Activity' app:

$ sudo -u www-data php ./occ app:enable activity

Refresh Nextcloud in your browser, go to the Apps menu and when trying to update/enable any of the other Apps you find that your admin password does not work, go to Issue/Error 1 and follow the steps. You may need to logout/login before the admin password will work again.

Issue/Error 6:

White/blank screen when every upgrade solution above is complete and you are trying to login.

Solution 6:

Verify that Redis/Memcached are setup correctly. See Configuring Memory Caching In Nextcloud. Check Nextcloud config and you may only just need to reboot the entire server (restarting the redis server may not be enough). After checking that redis was running and configured correctly, I just rebooted the server and everthing worked correctly.

To check the redis config file:

$ sudo nano /etc/redis/redis.conf

or could be the code below showing the redis server port number. The file below is when redis was using port 6379 instead of 0 (which is what is used in Configuring Memory Caching In Nextcloud and the ‘unixsocket /tmp/redis.sock' and ‘unixsocketperm 770' were left commented and unchanged) :

$ sudo nano /etc/redis/6379.conf

To check that Redis is running:
https://help.nextcloud.com/t/memcache-local-oc-memcache-redis-throws-misconfiguration/35313/13

$ redis-cli
> monitor

Now you can see what is happening live in the cache. The link above shows that if using the unixsocket and unixsocketperm parameters, you may need to use the code below to monitor the cache. Note that the file path below IS NOT found when unixsocket and unixsocketperm are commented out which is why there is no reference to a file path in the code above:

$ redis-cli -s /var/run/redis/redis.sock
> monitor

More references for redis and memcached:

https://help.nextcloud.com/t/permission-denied-for-redis/19806
and
https://stackoverflow.com/questions/19581059/misconf-redis-is-configured-to-save-rdb-snapshots

to stop it trying to save the snapshot:

$ redis-cli
> config set stop-writes-on-bgsave-error no

The db and the path to it can be obtained in redis-cli:

> CONFIG GET dir

> CONFIG GET dbfilename

and in the commandline ls -l. The permissions for the directory should be 755, and those for the file should be 644. Also, normally redis-server executes as the user redis, therefore its also nice to give the user redis the ownership of the folder by executing sudo chown -R redis:redis /path/to/rdb/folder

To revert back this command:

> config set stop-writes-on-bgsave-error yes

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.