Как обновить nextcloud на сервере
Перейти к содержимому

Как обновить nextcloud на сервере

  • автор:

Как правильно обновить NextCloud : NextCloud

Пришло время — вышла очередная версия NextCloud (удобно сделано обновление, в том числе — на телефон), как обновиться?

Сначала попробовал обновить через веб — не могло скачать, потом какой-то таймаут, потом какой-то огрызок страницы показало и закешировалось. Не рекомендую.

После того, как заклинило на «step 4 is currently in process. please reload this page later», что, скорее всего, не решится никогда, закрываете закладку с прогрессом, что дает гарантию незапуска следующего шага, идете в директорию
/var/www/nextcloud/data/updater-oc7anibltfqu
и удаляете там файлик .step, который и содержит статус обновления.

Гораздо более понятно работает скрипт обновлятора, запускаемый из под пользователя, под каким работает веб-сервер

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

можно вообще, чтобы не спрашивал, воткнуть в крон, что я бы не рекомендовал делать.

sudo -u www-data php /var/www/nextcloud/updater/updater.phar --no-interaction

Upgrade manually

If you upgrade from a previous major version please see critical changes first.

Always start by making a fresh backup and disabling all 3rd party apps.

  1. Back up your existing Nextcloud Server database, data directory, and config.php file. (See Backup , for restore information see Restoring backup )
  2. Download and unpack the latest Nextcloud Server release (Archive file) from nextcloud.com/install/ into an empty directory outside of your current installation.

Note To unpack your new tarball, run: unzip nextcloud-[version].zip or tar -xjf nextcloud-[version].tar.bz2

crontab -u www-data -e

chown -R www-data:www-data nextcloud find nextcloud/ -type d -exec chmod 750 <> \; find nextcloud/ -type f -exec chmod 640 <> \; 
sudo -u www-data php occ upgrade 

crontab -u www-data -e

Login and take a look at the bottom of your Admin page to verify the version number. Check your other settings to make sure they’re correct. Go to the Apps page and review the core apps to make sure the right ones are enabled. Re-enable your third-party apps.

Previous Nextcloud releases

You’ll find previous Nextcloud releases in the Nextcloud Server Changelog.

Troubleshooting

Occasionally, files do not show up after a upgrade. A rescan of the files can help:

sudo -u www-data php console.php files:scan --all 

Sometimes, Nextcloud can get stuck in a upgrade if the web based upgrade process is used. This is usually due to the process taking too long and encountering a PHP time-out. Stop the upgrade process this way:

sudo -u www-data php occ maintenance:mode --off 

Then start the manual process:

sudo -u www-data php occ upgrade 

If this does not work properly, try the repair function:

sudo -u www-data php occ maintenance:repair 

© Copyright 2024 Nextcloud GmbH.

Upgrade via built-in updater

The built-in updater automates many of the steps of upgrading a Nextcloud installation. It is useful for installations that do not have root access, such as shared hosting, for installations with a smaller number of users and data, and it automates updating manual installations .

Downgrading is not supported and risks corrupting your data! If you want to revert to an older Nextcloud version, install it from scratch and then restore your data from backup. Before doing this, file a support ticket if you have paid support or ask for help in the Nextcloud forums to see if your issue can be resolved without downgrading.

You should maintain regular backups (see Backup ), and make a backup before every update. The built-in updater does not backup your database or data directory.

What does the updater do?

The updater itself only replaces the existing files with the ones from the version it updates to. The migration steps needs to be executed afterwards. The command line mode provides a way to do this right after the code was successfully replaced.

The built-in updater performs these operations:

  • Check for expected files: checks if only the expected files of a Nextcloud installation are present, because it turned out that some files that were left in the Nextcloud directory caused side effects that risked the update procedure.
  • Check for write permissions: checks if all files that need to be writable during the update procedure are actually writable.
  • Enable maintenance mode: enables the maintenance mode so that no other actions are executed while running the update of the code.
  • Create backup: creates a backup of the existing code base in /updater-INSTANCEID/backups/nextcloud-CURRENTVERSION/ inside of the data directory (this does not contain the /data directory nor the database).
  • Downloading: downloads the code in the version it should update to. This is also shown in the web UI before the update is started. This archive is downloaded to /updater-INSTANCEID/downloads/ .
  • Extracting: extracts the archive to the same folder.
  • Replace entry points: replaces all Nextcloud entry points with dummy files so that when those files are replaced all clients still get the proper maintenance mode response. Examples for those endpoints are index.php , remote.php or ocs/v1.php .
  • Delete old files: deletes all files except the above mentioned entry points, the data and config dir as well as non-shipped apps and themes. (And the updater itself of course)
  • Move new files in place: moves the files from the extracted archive in place.
  • Keep maintenance mode active?: asks you if the maintenance mode should be kept active. This allows the admin to use the web based updater but run the actual migration steps ( occ upgrade ) on the command line. If the maintenance mode is kept active command line access is required. To use the web based upgrade page disable the maintenance mode and click the link to get to the upgrade page. (This step is only available in the web based updater.)
  • Done the update of the code is done and you either need to go to the linked page or to the command line to finish the upgrade by executing the migration steps.

Using the web based updater

Using the built-in updater to update your Nextcloud installation is just a few steps:

  1. You should see a notification at the top of any Nextcloud page when there is a new update available. Go to the admin settings page and scroll to the section “Version”. This section has a button to open the updater. This section as well as the update notification is only available if the update notification app is enabled in the apps management.

../_images/updater-1-update-available.png

  1. Click the button “Open updater”.

../_images/updater-2-open-updater.png

  1. Verify the information that is shown and click the button “Start update” to start the update.

../_images/updater-3-running-step.png

  1. In case an error happens or the check failed the updater stops processing and gives feedback. You can now try to solve the problem and click the “Retry update” button. This will continue the update and re-run the failed step. It will not re-run the previous succeeded steps.

../_images/updater-4-failed-step.png

  1. In case you close the updater, before it finished you can just open the updater page again and proceed at the last succeeded step. Closing the web page will still execute the running step but will not continue with the next one, because this is triggered by the open updater page.

../_images/updater-5-continue-update.png

  1. Once all steps are executed the updater will ask you a final question: “Keep maintenance mode active?”. This allows you to use either the web based upgrade page or the command line based upgrade procedure ( occ upgrade ). Command line access is required if the maintenance mode is kept active.

../_images/updater-6-maintenance-mode.png

  1. Done. You now can continue either to the web based upgrade page or run occ upgrade . The two examples “Web based upgrade” and “Command line based upgrade” shows how the screens then look like.

Web based upgrade

This is how the web based update would continue:

../_images/updater-7-disable-maintenance.png ../_images/updater-9-upgrade-page.png

Command line based upgrade

This is how the command line based update would continue:

../_images/updater-8-keep-maintenance.png

$ sudo -u www-data php ./occ upgrade 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 Updating . Updated to 1.1.1 Updating . Updated to 17.0.0 Updating . Updated to 2.5.2 Updating . Updated to 1.2.0 Updating . Updated to 1.3.0 Starting code integrity check. Finished code integrity check Update successful Maintenance mode is kept active Reset log level

Using the command line based updater

The command line based updater works in the exact same way the web based updater works. The steps and checks are the very same.

APCu is disabled by default on CLI which could cause issues with nextcloud’s command line based updater. Please make sure you set the apc.enable_cli to 1 on your php.ini config file or append —define apc.enable_cli=1 to the command line based updater call (like sudo -u www-data php —define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar ).

The steps are basically the same as for the web based updater:

  1. You should see a notification at the top of any Nextcloud page when there is a new update available. Go to the admin settings page and scroll to the section “Version”. This section has a button to open the updater. This section as well as the update notification is only available if the update notication app is enabled in the apps management.

../_images/updater-1-update-available.png

  1. Instead of clicking that button you can now invoke the command line based updater by going into the updater/ directory in the Nextcloud directory and executing the updater.phar as the web server user. (i.e. sudo -u www-data php /var/www/nextcloud/updater/updater.phar )

../_images/updater-cli-2-start-updater.png

  1. Verify the information that is shown and enter “Y” to start the update.

../_images/updater-cli-3-running-step.png../_images/updater-cli-4-failed-step.png

  1. In case an error happens or the check failed the updater stops processing and gives feedback. You can now try to solve the problem and re-run the updater command. This will continue the update and re-run the failed step. It will not re-run the previous succeeded steps.

../_images/updater-cli-5-continue-update.png

  1. Once all steps are executed the updater will ask you a final question: “Should the “occ upgrade” command be executed?”. This allows you to directly execute the command line based upgrade procedure ( occ upgrade ). If you select “No” then it will finish with Please now execute “./occ upgrade” to finish the upgrade. .

../_images/updater-cli-6-run-command.png

  1. Once the occ upgrade is done you get asked if the maintenance mode should be kept active.

../_images/updater-cli-7-maintenance.png

Batch mode for command line based updater

It is possible to run the command line based updater in a non-interactive mode. The updater then doesn’t ask any interactive questions. It is assumed that if an update is available it should be installed and the occ upgrade command is executed as well. After finishing the maintenance mode will be turned off except an error occured during the occ upgrade or the replacement of the code.

To execute this, run the command with the —no-interaction option. (i.e. sudo -u www-data php /var/www/nextcloud/updater/updater.phar —no-interaction )

../_images/updater-cli-8-no-interaction.png

© Copyright 2024 Nextcloud GmbH.

How to upgrade

There are three ways to upgrade your Nextcloud server:

  • With the Updater .
  • Manually upgrading with the Nextcloud .tar archive from our Download page.
  • Upgrading via the snap packages.
  • Manually upgrading is also an option for users on shared hosting; download and unpack the Nextcloud tarball to your PC. Delete your existing Nextcloud files, except data/ and config/ files, on your hosting account. Then transfer the new Nextcloud files to your hosting account, again preserving your existing data/ and config/ files.

When an update is available for your Nextcloud server, you will see a notification at the top of your Nextcloud Web interface. When you click the notification it brings you here, to this page.

It is best to keep your Nextcloud server upgraded regularly, and to install all point releases and major releases. Major releases are 18, 19 or 20. Point releases are intermediate releases for each major release. For example 18.0.4 and 19.0.2 are point releases.

  • Before you can upgrade to the next major release, Nextcloud upgrades to the latest point release.
  • Then run the upgrade again to upgrade to the next major release’s latest point release.
  • You cannot skip major releases. Please re-run the upgrade until you have reached the highest available (or applicable) release.
  • Example: 18.0.5 -> 18.0.11 -> 19.0.5 -> 20.0.2

Wait for background migrations to finish after major upgrades. After upgrading to a new major version, some migrations are scheduled to run as a background job. If you plan to upgrade directly to another major version (e.g. 24 -> 25 -> 26) you need to make sure these migrations were executed before starting the next upgrade. To do so you should run the cron.php file 2-3 times, for example:

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

For more information about background jobs see Background jobs .

Upgrading is disruptive. Your Nextcloud server will be put into maintenance mode, so your users will be locked out until the upgrade is completed. Large installations may take several hours to complete the upgrade. Nevertheless usual upgrade times even for bigger installations are in the range of a few minutes.

Downgrading is not supported and risks corrupting your data! If you want to revert to an older Nextcloud version, make a new, fresh installation and then restore your data from backup. Before doing this, file a support ticket (if you have paid support) or ask for help in the Nextcloud forums to see if your issue can be resolved without downgrading.

Update notifications

Nextcloud has an update notification app, that informs the administrator about the availability of an update. Then you decide which update method to use.

Both update notifications displayed on Admin page.

From there the web based updater can be used to fetch this new code. There is also an CLI based updater available, that does exactly the same as the web based updater but on the command line.

Prerequisites

If you upgrade from a previous major version please see critical changes first.

You should always maintain regular backups and make a fresh backup before every upgrade.

Then review third-party apps, if you have any, for compatibility with the new Nextcloud release. Any apps that are not developed by Nextcloud show a 3rd party designation. Install unsupported apps at your own risk. Then, before the upgrade, all 3rd party apps must be disabled. After the upgrade is complete you may re-enable them.

Maintenance mode

You can put your Nextcloud server into maintenance mode before performing upgrades, or for performing troubleshooting or maintenance. Please see Using the occ command to learn how to put your server into the maintenance mode ( maintenance:mode ) or execute repair commands ( maintenance:repair ) with the occ command.

The build-in Updater does this for you before replacing the existing Nextcloud code with the code of the new Nextcloud version.

maintenance:mode locks the sessions of logged-in users and prevents new logins. This is the mode to use for upgrades. You must run occ as the HTTP user, like this example on Ubuntu Linux:

$ sudo -u www-data php occ maintenance:mode --on

You may also put your server into this mode by editing config/config.php . Change «maintenance» => false to «maintenance» => true :

 true,

Then change it back to false when you are finished.

Manual steps during upgrade

Some operation can be quite time consuming. Therefore we decided not to add them to the normal upgrade process. We recommend to run them manually after the upgrade was completed. Below you find a list of this commands.

Long running migration steps

From time to time we do some changes to the database layout that take a lot of time, but can be executed while Nextcloud stays online. Thus we moved them into a separate command that an administrator can execute on the CLI without the need to lock the instance into maintenance mode (at least for some of them). The instance will also work without those changes applied, but performance is improved significantly by them. There is also always an hint in the setup checks of the admin settings web interface.

Those include for example:

$ sudo -u www-data php occ db:add-missing-columns $ sudo -u www-data php occ db:add-missing-indices $ sudo -u www-data php occ db:add-missing-primary-keys

You can use the —dry-run option to output the SQL queries instead of executing them.

© Copyright 2024 Nextcloud GmbH.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *