Nextcloud update using cli only

Nextcloud X → Nextcloud Y


Nextcloud can be updated using the Nextcloud command line interface only. Even your enabled apps will be updated as far as they are available on the Nextcloud app store. But first backup your Nextcloud system (database and data).


Last Updates:

February, 01st 2019:
– compatible with APACHE2 and added an app update example


On NGINX environments

sudo -s
cd /var/www/nextcloud
/usr/sbin/service nginx stop

or on APACHE2 environments

sudo -s
cd /var/www/html/nextcloud
/usr/sbin/service apache2 stop

Start the update

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

Press y to start updating your Nextcloud and y again to continue

Now the code was updated. Press n to disable Nextclouds maintenance mode and the update has ben finished already.

You are on the latest Nextcloud release – it can be verifed by

sudo -u www-data php occ status
sudo -u www-data php occ -V

On NGINX environments modify Nextclouds .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

or on Apache2 environments modify Nextclouds (.htaccess) as described here

...
<IfModule mod_php7.c>
php_value upload_max_filesize 10240M
php_value post_max_size 10240M
php_value memory_limit 512M
php_value mbstring.func_overload 0
php_value default_charset 'UTF-8'
php_value output_buffering 'Off'
<IfModule mod_env.c>
...
ErrorDocument 403 /
ErrorDocument 404 /
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg)$
RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
RewriteCond %{REQUEST_FILENAME} !core/img/manifest.json$
RewriteCond %{REQUEST_FILENAME} !/remote.php
RewriteCond %{REQUEST_FILENAME} !/public.php
RewriteCond %{REQUEST_FILENAME} !/cron.php
RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
RewriteCond %{REQUEST_FILENAME} !/status.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
RewriteCond %{REQUEST_FILENAME} !/robots.txt
RewriteCond %{REQUEST_FILENAME} !/updater/
RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
RewriteRule . index.php [PT,E=PATH_INFO:$1]
RewriteBase /
<IfModule mod_env.c>
SetEnv front_controller_active true
<IfModule mod_dir.c>
DirectorySlash off
</IfModule>
</IfModule>
</IfModule>

Verify all indices are properly set and everything ist up to date:

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

Restart both, PHP and NGINX

/usr/sbin/service php7.3-fpm restart
/usr/sbin/service nginx restart

or PHP and APACHE2

/usr/sbin/service php7.3-fpm restart
/usr/sbin/service apache2 restart

Keep it simple – download all as a shell script for NGINX based environments

Nextcloud-upgrade-on-ubuntu.sh

Nextcloud-upgrade-on-debian.sh

If app updates are found just issue

sudo -u www-data php occ app:update --all

or

sudo -u www-data php occ app:update <app-name>

sudo -u www-data php occ app:update contacts

Done!


Enjoy your personal data in your secured and hardened Nextcloud-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.

5 Responses

  1. Marco says:

    Hi,

    ich habe dein Script für die Nextcloud Installation benutzt, danke dafür.
    Allerdings habe ich nun folgende Fehlermeldung wenn ich von Version 14.0.3 auf Version 14.0.4 aktualisieren möchte.

    ***
    Could not copy “/var/www/nextcloud/config/config.php.orig” to “/var/nc_data/updater-oc751ztl6eab/backups/nextcloud-14.0.3.0/config/config.php.orig”. Source /var/www/nextcloud/config/config.php.orig is not readable. Destination /var/nc_data/updater-oc751ztl6eab/backups/nextcloud-14.0.3.0/config/config.php.orig is not writable
    ***

    Kannst du mir sagen wie ich das beheben kann?

    Besten Dank.

  2. Manni says:

    .. wieder mal eine geniale meisterliche Anleitung. :o))))))

    Wenn man sich an die Anleitungen hält, klappt das mit dem Nachbar, ähh Nextcloud.

Leave a Reply

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