IT in Education

How to upgrade Nextcloud

nextcloudNew versions of Nextcloud are released on a regular basis.  This article describes how to upgrade to the latest version (I'm upgrading to Nextcloud 21 at the time of writing).


Backup

Before performing any upgrade tasks you must make sure that you have a valid backup of your Nextcloud instance.

Apps

Prior to upgrading you must disable any third party apps, you can enable them after the upgrade is complete. You also need to check for any updates to your installed apps.

  1. Start by logging in with an admin account.
  2. Click your Avatar > Apps.
  3. Select Active Apps in the left pane.
    1. Disable any apps that aren't labelled as Featured.
  4. Select Updates in the left pane (only visible if updates are available).
    1. Click the Update button for individual apps, or Update all.

Note that if you don't update apps in this step, they should be updated as part of the process below.

Locked files

It's also a good time to see if there are any files that have been locked but not reported.

Web based updater

Nextcloud has its own built-in web based updater. The update process includes checking for any 'unknown' files or folders. You will need to remove any that are discovered before the upgrade can go ahead.

  1. Go to the Settings page (click your avatar, top-right).
  2. Select Administration > Overview in the left pane.
  3. Check to see if All apps have an update for this version available.
    1. You can expand the Apps with available updates to see more info.
  4. Click the Open updater button.
  5. Click Start update.
  6. Click the No (for usage of the web based updater) button.
  7. Click Go back to your Nextcloud instance to finish the update.
    1. Make a note of information on this screen.
  8. Click the Start update button to apply the update to your database.

Command line upgrade

Using OCC commands to perform the upgrade is generally quicker and safer. Start by accessing your web server using SSH.

  1. Go to the Settings page (click your avatar, top-right).
  2. Select Administration > Overview in the left pane.
  3. Check to see if All apps have an update for this version available.
    1. You can expand the Apps with available updates to see more info.
  4. Click the Open updater button.
  5. Click Start update.
  6. Click Yes (for usage of the command line tool) button.
  7. Run the following OCC command:
php ./occ upgrade

Alternatively you can run the following OCC commands:

php /path/to/nextcloud/updater/updater.phar
php ./occ upgrade

Or to run the same commands but without user interaction:

php ./updater/updater.phar --no-interaction

Tidying up

If you disabled any third party apps, you can now check to see if they have any updates, and then re-enable them.

If you are using a theme, you will need to edit the config/config.php file in order to reinstate it. Additionally the .htaccess file gets overwritten as part of the upgrade process, so you will need to add in the settings to force SSL and any fixes for Security and setup warnings.

The default favicon at /core/img/favicon.ico will get overwritten and don't forget to move back any files or folders that you might've removed as part of the upgrade process.

This upgrade process creates a backup directory that you can visit and remove any older backups that you no longer need. Depending on your instance, these backup directories can take up a considerable amount of space.

/data/updater=xxxxxxxx/backups/

Troubleshooting

Step 4 is currently in process

If during the upgrade the download fails, you will get the following error message:

Step 4 is currently in process. Please reload this page later

To fix this issue:

  1. Download the file manually from Nextcloud (e.g. nextcloud-18.0.9.zip)
  2. Upload the complete download and replace the incomplete file located at /data/update-xxxxxxxxx/downloads
  3. Edit the /data/update-xxxxxx/.step file as follows:
{"state": "end", "step":4}

Now you can continue by reloading the update page.

Here is an alternative method that I also found to work:

  1. Turn maintenance mode off
  2. Delete the /data/update-xxxxx/.step file.
  3. Check some PHP parameters.
    1. max_execution_time 120 seconds
    2. max_input_time 90 seconds


Thanks for visiting,
Steven