Upgrade to Nextcloud 14


Upgrade to the brandnew Nextcloud 14 as simple as that:

You can decide whether to perform the upgrade by issuing Nextclouds webupdater or to do it manually (my preferred scenario). 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 called 13.0.6

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

Second ensure that all of your apps are ready for Nextcloud 14 yet using the app “Can I update”.

Perform a backup of your Nextcloud instance and verify the backup before you start! 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 coturn 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/nextcloud1306

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 14 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/nextcloud1306/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

Perform the upgrade in your preferred browser.

You will be forwarded to your Nextcloud 14 instance

Verify you are on Nextcloud 14

Issue two statements to configure your database as recommended:

sudo -u www-data php occ db:add-missing-indices
sudo -u www-data php occ db:convert-filecache-bigint

Delete the previous moved files

rm -R /var/www/nextcloud1306

and edit the new .user.ini:

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

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 and mark it as executable

chmod +x /root/optimize.sh

Issue the optimize.sh script initially:

/root/optimize.sh

Verify all checks passed:

That’s it!


Enjoy your personal data in your secured and hardened Nextcloud 14 Server!

Don’t forget to backup your Nextcloud

Find more instructions here: Nextcloud Backup and Restore



Carsten Rieger

18 Responses

  1. 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:
    OCP\AppFramework\QueryException: 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): OC\AppFramework\Utility\SimpleContainer->resolve(‘defaultTokenPro…’)
    #1 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘defaultTokenPro…’)
    #2 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): OC\ServerContainer->query(‘defaultTokenPro…’)
    #3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(104): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
    #4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OC\AppFramework\Utility\SimpleContainer->resolve(‘OC\\Authenticati…’)
    #5 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\\Authenticati…’)
    #6 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\ServerContainer->query(‘OC\\Authenticati…’)
    #7 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
    #8 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘OC\\Authenticati…’)
    #9 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\\Authenticati…’)
    #10 /var/www/nextcloud/lib/private/Server.php(364): OC\ServerContainer->query(‘OC\\Authenticati…’)
    #11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
    #12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘OCP\\IUserSessio…’)
    #13 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\\IUserSessio…’)
    #14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\ServerContainer->query(‘OCP\\IUserSessio…’)
    #15 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
    #16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘UserSession’)
    #17 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘UserSession’)
    #18 /var/www/nextcloud/lib/private/Server.php(1415): OC\ServerContainer->query(‘UserSession’)
    #19 /var/www/nextcloud/lib/private/Server.php(1023): OC\Server->getSession()
    #20 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
    #21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘OC\\Security\\CSR…’)
    #22 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\\Security\\CSR…’)
    #23 /var/www/nextcloud/lib/private/Server.php(1019): OC\ServerContainer->query(‘OC\\Security\\CSR…’)
    #24 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
    #25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘CsrfTokenManage…’)
    #26 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘CsrfTokenManage…’)
    #27 /var/www/nextcloud/lib/private/Server.php(1878): OC\ServerContainer->query(‘CsrfTokenManage…’)
    #28 /var/www/nextcloud/lib/private/Server.php(815): OC\Server->getCsrfTokenManager()
    #29 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
    #30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘OCP\\IRequest’)
    #31 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\\IRequest’)
    #32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\ServerContainer->query(‘OCP\\IRequest’)
    #33 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
    #34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘Request’)
    #35 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘Request’)
    #36 /var/www/nextcloud/lib/private/Server.php(1282): OC\ServerContainer->query(‘Request’)
    #37 /var/www/nextcloud/lib/private/Server.php(454): OC\Server->getRequest()
    #38 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
    #39 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘OCP\\L10N\\IFacto…’)
    #40 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\\L10N\\IFacto…’)
    #41 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\ServerContainer->query(‘OCP\\L10N\\IFacto…’)
    #42 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
    #43 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(123): Pimple\Container->offsetGet(‘L10NFactory’)
    #44 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘L10NFactory’)
    #45 /var/www/nextcloud/lib/private/Server.php(1468): OC\ServerContainer->query(‘L10NFactory’)
    #46 /var/www/nextcloud/lib/private/Server.php(1479): OC\Server->getL10NFactory()
    #47 /var/www/nextcloud/lib/base.php(234): OC\Server->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 OCP\AppFramework\QueryException: 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): OC\AppFramework\Utility\SimpleContainer->resolve(‘defaultTokenPro…’)
    #1 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘defaultTokenPro…’)
    #2 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): OC\ServerContainer->query(‘defaultTokenPro…’)
    #3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(104): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
    #4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(125): OC\AppFramework\Utility\SimpleContainer->resolve(‘OC\\Authenticati…’)
    #5 /var/www/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\Simp in /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 110
    root@cloud:~#

  2. 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

  3. 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

      • Simo Chalich says:

        Yes I did.
        And now for second time just to be sure. Unfortunately no result. Noticed also that always the first login is unsuccessful. Need to enter username and password twice before logging in. Otherwise Settings –> Overview shows: All checks passed.

  4. 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

  5. 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!

  6. 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. 🙂

  7. 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 …

  8. 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 *