How to update Nextcloud?

I previously posted a step-by-step tutorial on how to install Nextcloud from scratch.

However, it is important to keep your Nextcloud installation updated and while the built-in updater the software provides is likely the easiest way to do so, I have honestly never succeeded in using it without it encountering error in between the process.

The following tutorial will teach you how to update Nextcloud manually:

  1. Backup your Nextcloud database and folder
  2. Enable maintenance mode

    cd /var/www/nextcloud
    sudo -u www-data php occ maintenance:mode --on

  3. Rename your existing Nextcloud folder

    sudo mv /var/www/nextcloud /var/www/nextcloud-old

  4. Download Nextcloud (check the latest version and replace the value below accordingly) and move the directory to your existing Nextcloud location

    cd ~
    wget https://download.nextcloud.com/server/releases/nextcloud-20.0.6.zip
    unzip nextcloud-20.0.6.zip
    sudo mv ~/nextcloud /var/www/nextcloud

  5. Move the following directories from the previous directory to the latest one and update the permissions accordingly

    sudo mv /var/www/nextcloud-old/config/config.php /var/www/nextcloud/config
    sudo mv /var/www/nextcloud-old/data /var/www/nextcloud
    sudo rm -rf /var/www/nextcloud/apps
    sudo mv /var/www/nextcloud-old/apps /var/www/nextcloud
    sudo chown -R www-data:www-data /var/www/nextcloud/ && sudo chmod -R 755 /var/www/nextcloud/

  6. Restart the server

    sudo systemctl restart nginx

  7. Proceed to upgrade Nextcloud

    cd /var/www/nextcloud
    sudo -u www-data php occ upgrade

  8. Disable maintenance mode

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

  9. Check your Nextcloud and if everything is successful, you may delete the old directory

    sudo rm -rf /var/www/nextcloud-old

2021-02-01

index