How to force the upgrade to Nextcloud 15


Force the upgrade to Nextcloud 15


Are you still waiting for Nextcloud 15?

Just upgrade manually. It might become necessary to re-enable your previous enabled apps whereas the webupdater would handle it by itself, but from my perspective it is more stable and reliable to perform the upgrade manually.

First ensure you are already on the latest Nextcloud Release 14.0.4.

sudo -s
sudo -u www-data php /var/www/nextcloud/occ -V

Second ensure that all of your apps are ready for Nextcloud 15 yet (https://apps.nextcloud.com).


Attention: with regards to the enabled user_external app – the update will fail with a message like

...The files of the app External user support (user_external) were not replaced correctly...

Please issue

sudo -u www-data php /var/www/nextcloud/occ app:disable user_external

to disable the user_external app befor you start the upgrade. Please follow @github for further details. Thanks to Detlef


Perform a backup of your Nextcloud instance and verify the backup before you begin! Then stop all services related to your Nextcloud using a stop.sh script.

vi /root/stop.sh

#!/bin/bash
/usr/sbin/service nginx stop
/usr/sbin/service php7.2-fpm stop
/usr/sbin/service redis-server stop
/usr/sbin/service mysql stop
exit 0

Mark it as executable and issue the script.

chmod +x /root/stop.sh && /root/stop.sh

Move the old Nextcloud directory

mv /var/www/nextcloud /var/www/nextcloud1404

and verify, you applied the last updates to the header.conf

vi /etc/nginx/header.conf

If not, just replace the old referrer-policy with the the new red one:

add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer" always;

Then download and extract the Nextcloud 15 release, delete the downloaded file and apply the proper permissions:

wget https://download.nextcloud.com/server/releases/latest.tar.bz2 && tar -xjf latest.tar.bz2 -C /var/www && chown -R www-data:www-data /var/www/ && rm latest.tar.bz2
chown -R www-data:www-data /var/www

Copy the old config.php to the new directory

sudo -u www-data cp /var/www/nextcloud1404/config/config.php /var/www/nextcloud/config/

Restart all services using a restart.sh script

vi /root/restart.sh
#!/bin/bash
/usr/sbin/service mysql restart
/usr/sbin/service redis-server restart
/usr/sbin/service php7.2-fpm restart
/usr/sbin/service nginx restart
exit 0

Mark it as executable and issue the script.

chmod +x /root/restart.sh && /root/restart.sh

Call your Nextcloud in your browser and perform the upgrade. Wait few seconds until you’ll be forwarded to your Nextcloud 15 instance

Verify you are on Nextcloud 15 stable

and logout. Create or download the upgrade.sh and issue the script:

vi /root/upgrade-ubuntu.sh
#!/bin/bash
/usr/sbin/service nginx stop
sudo -u www-data php /var/www/nextcloud/updater/updater.phar
sudo -u www-data php /var/www/nextcloud/occ status
sudo -u www-data php /var/www/nextcloud/occ -V
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
sudo -u www-data php /var/www/nextcloud/occ db:convert-filecache-bigint
sudo -u www-data sed -i "s/upload_max_filesize=.*/upload_max_filesize=10240M/" /var/www/nextcloud/.user.ini
sudo -u www-data sed -i "s/post_max_size=.*/post_max_size=10240M/" /var/www/nextcloud/.user.ini
sudo -u www-data sed -i "s/output_buffering=.*/output_buffering='Off'/" /var/www/nextcloud/.user.ini
sudo -u www-data php /var/www/nextcloud/occ update:check
/usr/sbin/service php7.2-fpm restart
/usr/sbin/service nginx restart
exit 0

Save the script, mark it as executable and issue it:

chmod +x /root/upgrade-ubuntu.sh && /root/upgrade-ubuntu.sh

Delete the previous moved Nextcloud 14 files

rm -R /var/www/nextcloud1404

Finally optimize your new Nextcloud using the optimize.sh script:

vi /root/optimize.sh
#!/bin/bash
redis-cli -s /var/run/redis/redis-server.sock <<EOF
FLUSHALL
quit
EOF
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
sudo -u www-data php /var/www/nextcloud/occ files:scan-app-data
exit 0

Save the script, mark it as executable and issue it:

chmod +x /root/optimize.sh && /root/optimize.sh

Verify all checks passed:

That’s it! Enjoy your personal data in your secured and hardened Nextcloud 15 Server!


Don’t forget to backup your Nextcloud

Find more instructions here: Nextcloud backup and restore



Carsten Rieger

Carsten Rieger

Carsten Rieger is a senior system engineer in full-time and also working as an IT freelancer. He is working with linux environments for more than 13 years, an Open Source enthusiast and highly motivated on linux installation and troubleshooting. Mostly working with Debian/Ubuntu Linux, Nginx and Apache web server, MariaDB/MySQL/PostgreSQL, PHP, Cloud infrastructure (e.g. Nextcloud) and other open source projects (e.g. Roundcube) and in voluntary work for the Dr. Michael & Angela Jacobi Stiftung for more than 7 years.

27 Responses

  1. Detlef says:

    Hi Carsten, great piece – as usual 😉 – and just in time, ’cause davdroid had just failed. Some minor things to mention:
    1 “caniupdate”-app has a comment, that it is not needed anymore – and does not show.
    2 When restarting NC at the end it responds: Fehler The files of the app External user support (user_external) were not replaced correctly. Make sure it is a version compatible with the server.
    3 Using the tip from scurrvy2020 on github https://github.com/nextcloud/server/issues/12024 and disabling user_external enables the completion of the update to 15 but leaves user_external issue open

  2. sascha says:

    in the upgrade-ubuntu.sh you mentioned
    chown +x /root/upgrade-ubuntu.sh && /root/upgrade-ubuntu.sh
    but it should be
    chmod instead

  3. Darek says:

    Thanks to your tutorial, I already have Nextcloud 15. Thank you again. I have sent a tweet @Nextcloud with a link to your tutorials. Unfortunately, they did not retweet :).

  4. Geofrey gachie says:

    I am experiencing an issue when i try to run the upgrade .Below is a log i am getting ,please help.

    ncadmin@cloud:~$ sudo -s
    [sudo] password for ncadmin:
    root@cloud:~# sudo -u www-data php /var/www/nextcloud/occ -V
    An unhandled exception has been thrown:
    OCPAppFrameworkQueryException: Could not resolve defaultTokenProvider! Class defaultTokenProvider does not exist in /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php:110
    Stack trace:
    #0 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OCAppFrameworkUtilitySimpleContainer->resolve(‘defaultTokenPro…’)
    #1 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘defaultTokenPro…’)
    #2 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): OCServerContainer->query(‘defaultTokenPro…’)
    #3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(104): OCAppFrameworkUtilitySimpleContainer->buildClass(Object(ReflectionClass))
    #4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OCAppFrameworkUtilitySimpleContainer->resolve(‘OC\Authenticati…’)
    #5 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OC\Authenticati…’)
    #6 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OCServerContainer->query(‘OC\Authenticati…’)
    #7 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OCAppFrameworkUtilitySimpleContainer->OCAppFrameworkUtility{closure}(Object(OCServer))
    #8 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘OC\Authenticati…’)
    #9 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OC\Authenticati…’)
    #10 /var/www/nextcloud/lib/private/Server.php(364): OCServerContainer->query(‘OC\Authenticati…’)
    #11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCServer->OC{closure}(Object(OCServer))
    #12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘OCP\IUserSessio…’)
    #13 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OCP\IUserSessio…’)
    #14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OCServerContainer->query(‘OCP\IUserSessio…’)
    #15 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OCAppFrameworkUtilitySimpleContainer->OCAppFrameworkUtility{closure}(Object(OCServer))
    #16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘UserSession’)
    #17 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘UserSession’)
    #18 /var/www/nextcloud/lib/private/Server.php(1415): OCServerContainer->query(‘UserSession’)
    #19 /var/www/nextcloud/lib/private/Server.php(1023): OCServer->getSession()
    #20 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCServer->OC{closure}(Object(OCServer))
    #21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘OC\Security\CSR…’)
    #22 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OC\Security\CSR…’)
    #23 /var/www/nextcloud/lib/private/Server.php(1019): OCServerContainer->query(‘OC\Security\CSR…’)
    #24 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCServer->OC{closure}(Object(OCServer))
    #25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘CsrfTokenManage…’)
    #26 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘CsrfTokenManage…’)
    #27 /var/www/nextcloud/lib/private/Server.php(1878): OCServerContainer->query(‘CsrfTokenManage…’)
    #28 /var/www/nextcloud/lib/private/Server.php(815): OCServer->getCsrfTokenManager()
    #29 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCServer->OC{closure}(Object(OCServer))
    #30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘OCP\IRequest’)
    #31 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OCP\IRequest’)
    #32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OCServerContainer->query(‘OCP\IRequest’)
    #33 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OCAppFrameworkUtilitySimpleContainer->OCAppFrameworkUtility{closure}(Object(OCServer))
    #34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘Request’)
    #35 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘Request’)
    #36 /var/www/nextcloud/lib/private/Server.php(1282): OCServerContainer->query(‘Request’)
    #37 /var/www/nextcloud/lib/private/Server.php(454): OCServer->getRequest()
    #38 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OCServer->OC{closure}(Object(OCServer))
    #39 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘OCP\L10N\IFacto…’)
    #40 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘OCP\L10N\IFacto…’)
    #41 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OCServerContainer->query(‘OCP\L10N\IFacto…’)
    #42 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OCAppFrameworkUtilitySimpleContainer->OCAppFrameworkUtility{closure}(Object(OCServer))
    #43 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): PimpleContainer->offsetGet(‘L10NFactory’)
    #44 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘L10NFactory’)
    #45 /var/www/nextcloud/lib/private/Server.php(1468): OCServerContainer->query(‘L10NFactory’)
    #46 /var/www/nextcloud/lib/private/Server.php(1479): OCServer->getL10NFactory()
    #47 /var/www/nextcloud/lib/base.php(234): OCServer->getL10N(‘lib’)
    #48 /var/www/nextcloud/lib/base.php(659): OC::checkConfig()
    #49 /var/www/nextcloud/lib/base.php(1070): OC::init()
    #50 /var/www/nextcloud/console.php(46): require_once(‘/var/www/nextcl…’)
    #51 /var/www/nextcloud/occ(11): require_once(‘/var/www/nextcl…’)
    #52 {main}PHP Fatal error: Uncaught OCPAppFrameworkQueryException: Could not resolve defaultTokenProvider! Class defaultTokenProvider does not exist in /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php:110
    Stack trace:
    #0 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OCAppFrameworkUtilitySimpleContainer->resolve(‘defaultTokenPro…’)
    #1 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimpleContainer->query(‘defaultTokenPro…’)
    #2 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): OCServerContainer->query(‘defaultTokenPro…’)
    #3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(104): OCAppFrameworkUtilitySimpleContainer->buildClass(Object(ReflectionClass))
    #4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OCAppFrameworkUtilitySimpleContainer->resolve(‘OC\Authenticati…’)
    #5 /var/www/nextcloud/lib/private/ServerContainer.php(132): OCAppFrameworkUtilitySimp in /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 110
    root@cloud:~#

  5. Detlef says:

    Hi Carsten, works like a charm – great job. Many thx. Two minor hickups:
    stop & start script deal with coturn.service, which is not installed – does it make sense for my lill private install – where can I get this?
    optimize.sh scirpt deals with redis – am getting the response: “Could not connect to Redis at /var/run/redis/redis-server.sock: No such file or directory”. OK to change optimize.sh to /var/run/redis/redis.sock?
    Everything else worked just fine.
    Detlef

    • Dear Detlef, the coturn statement has been removed already, thank you! Regarding Redis-Server: it seems you are on Ubuntu 16.x – so feel free to change the redis socket path. But (redis-server.sock) it is correct for Ubuntu 18.x environments. Cheers, Carsten

  6. Simo Chalich says:

    Hi Carsten!
    Great tutorials. Thanks!

    After upgrading from 13.06 to 14.0 following this tutorial the browsing thru folders is quite complicated. If I click to a folder it does not open. The only way is to refresh the page with F5. And when I try to download a file I get the message:

    Internal Server Error

    The server was unable to complete your request.

    If this happens again, please send the technical details below to the server administrator.

    More details can be found in the server log.
    Technical details

    Remote Address: xxx.xxx.xxx.xxx
    Request ID: 2nLmdUHKbMh0PPfmwb7W

    Tried with different browsers, but the result is the same. Also tried to disable almost all apps, but again with no result.
    The mobile and desktop apps are working fine.
    Tried to Google the problem, but unfortunately my technical experience is not so good.

    Thanks for your time.
    Regards Simo.

    • Did you flush Redis and restart all services already? Try this:
      redis-cli -s /var/run/redis/redis-server.sock
      FLUSHALL
      quit
      sudo -u www-data php /var/www/nextcloud/occ files:scan –all
      sudo -u www-data php /var/www/nextcloud/occ files:scan-app-data
      /usr/sbin/service nginx stop
      /usr/sbin/service mysql restart
      /usr/sbin/service redis-server restart
      /usr/sbin/service php7.2-fpm restart
      /usr/sbin/service nginx restart

  7. Frank says:

    Hey Carsten today I updated to NC14. After the update process was finished I had run your optimize.sh script. Now when I look into the overview of my Nextcloud instance I see the following message:

    Der “Referrer-Policy” HTTP-Header ist nicht gesetzt auf “no-referrer”, “no-referrer-when-downgrade”, “strict-origin” oder “strict-origin-when-cross-origin”. Dadurch können Verweis-Informationen preisgegeben werden. Siehe die W3C-Empfehlung.

    Any hints?

    Thanks,
    ank0m

    • Sure, just update your /etc/nginx/header.conf to mine or replace the following line in there: add_header Referrer-Policy "no-referrer" always; and restart your nginx (service nginx restart). The message will disappear. 😉 Cheers, (viele Grüße!) Carsten

  8. Jens Mueller says:

    Hello, does not have to be copied after the update also the old user.ini again?

    • Yes, you’re absolutely right. I added the following statements already: sudo -u www-data sed -i "s/upload_max_filesize=.*/upload_max_filesize=10240M/" /var/www/nextcloud/.user.ini && sudo -u www-data sed -i "s/post_max_size=.*/post_max_size=10240M/" /var/www/nextcloud/.user.ini && sudo -u www-data sed -i "s/output_buffering=.*/output_buffering='Off'/" /var/www/nextcloud/.user.ini && service php7.2-fpm restart && service redis-server restart && service nginx restart
      Thank you very much!

  9. Ed says:

    Thank you Carsten! You are the best for quickly publishing this guide. Followed the guide and works like a charm. Nextcloud 14 rocks. 🙂

  10. Damir says:

    Hello Carsten,

    after the Upgrade i get the following error “No cache entry found for /appdata_oci6tfgyvogb/css/icons/icons-vars.css (storage: local::/var/nc_data/, internalPath: appdata_oci6tfgyvogb/css/icons/icons-vars.css)”.

    So “No cache…” then i remember to use your optimize.sh && restart.sh and voila running nicely again 🙂

    Maybe a hint for all whois getting this error …

  11. Robin says:

    The last commands to fix the DB don’t work.

    root@nextcloud:/var/www# sudo -u www-data php occ db:add-missing-indices
    Could not open input file: occ

    and

    root@nextcloud:/var/www# sudo -u www-data php occ db:convert-filecache-bigint
    Could not open input file: occ

Leave a Reply

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