Your own cloud: Nextcloud update on a Synology DiskStation and DSM 6

In the last article I’ve explained, how to fix common errors and security issues and how to optimize Nextcloud in a productive environment. In this article I’m going to show you how to update Nextcloud, once manually and once with the new updater app.
 

Manual Update

 

  1. First create an backup of your Nextcloud database.
  2. Maintenance mode.
    1. Open a connection to your DS via putty.
    2. Log in as an admin.
    3. Get root access typing sudo -i and your password.
    4. Go to your Nextcloud directory in /volumeX/web.
    5. Activate the maintenance mode typing:

      On a DiskStation you have to use http as user and type php56 to be able to use occ commands. Alternatively you can enable the maintenance mode in config.php directly.
  3. Stop the web server (stop the WebStation at the package center).
  4. Rename your Nextcloud folder in /volumeX/web (e.g. Nextcloud-Old).
  5. Download the newest Nextcloud release here.
  6. Upload the archive to your DiskStation and extrackt it to /volumeX/web.
    • Rename the folder if you used a different name four it before.
  7. Copy the config.php from the old directory to the new one.
  8. If your data directory is located in you Nextcloud directory, your also have to move it. If it is located outside of /web, you have to do nothing. The path is written down in the config.php file.
  9. If you have installed 3rd party apps, look into /apps if they are located there. If not, you also have to copy them. Attention: Only do this for apps you have actually installed. Skip apps that you don’t know and can’t find in the new /apps folder. Sometimes apps get discarded in ne Nextcloud versions, then you won’t find them in /apps anymore.

Modify permissions

  1. Create a script on your DiskStaton containing following lines:

    If you used this article to install Nextcloud and you already have this script you could skip this step. You could also modify the permissions via putty or WinSCP. I recommend the scripts because you have to tweak the permissions at every update. You save some time by just executing the scripts and not type every line into putty.
  2. Execute these lines via putty or execute the script typing sh /volumeX/path/to/script.sh

    Permissions before an update
    Permissions before an update

Execute the update

  1. Restart the web server.
  2. In putty, go to your Nextcloud folder.
  3. Deactivate the maintenance mode again. It seems that the update command enables the maintenance mode itself. If the mode is already active, the update can’t be executed:

  4. Exectue the update command:

  5. Based on the size of your installation, this will take some time. The command line writes down each single step and also informs you about the end of the update process.

    Update process in the command line
    Update process in the command line
  6. Now you have to deactivate the maintenance mode again:

  7.  Your Nextcloud is now up-to-date, continue with the steps from after updating NC.

 

Update using the updater app

 
ATTENTION: For a stable and working updater app, you need Nextcloud 10.0.1 or higher. Older versions and Owncloud still use the old Owncloud updater. This app is quite unstable and doesn’t even deliver newer versions of Owncloud and Nextcloud.

To update your Nextcloud, you have to wait, till the update is delivered via updater. In this case you’ll get a notification, you can see this notification in your web interface and also on all Nextcloud clients.

Update notification
Update notification

Modify permissions:

This is the only Task, the updater won’t do (on purpose). You have to set less strict permissions so that the updater is able to access the files. The best way to do this, is using putty or WinSCP. If you’ve already read the first article of this series and created the script before, you can skip this step and continue at step 2.

  1. Create somewhere on you DS a scipt (text file with the endin .sh), containing following lines:
  2. Open a connection to your DS via putty.
  3. Log in as an admin.
  4. Get root access typing sudo -i and your password.
  5. Enter these lines or execute the script by entering sh /volumeX/Pfad/zum/Script.sh

Execute the update:

  1. Log into the Nextcloud web interface.
  2. Go to the admin area. There you should see which version you use and which version is available.
  3. Open the updater by clicking the button. The updater again shows the version information.
Actual version and updater in the admin area
Actual version and updater in the admin area
Updater displaying version info
Updater displaying version info

The updater executes some security checks before the actual update gets performed. One of the checks looks for files or folders that are not part of the Nextcloud installation anymore. You have to delete them from the file system manually. After that you could restart the update by clicking the button.

Failed file check
Failed file check

The next task is the check for permissions. This task fails, if you haven’t modified the permissions before. The execution of this task will take some time.

Checking file permissions
Checking file permissions

The updater also creates a backup before it replaces the old installation with the new one.

Update the database:

You can do this in 2 different ways. Either you use the web interface or the command line (putty). In cases of large databases you can run into a PHP timeout. In this case you have to use the command line. Keep the maintenance mode active by clicking “Yes” and continue at “Execute the update” step 4 of the manual Update Chapter.

Keep maintenance mode or not
Keep maintenance mode or not
  1. To use the web interface for the update, click “No”.
  2. A new button appears, click on it to open the web interface.
  3. Now you can start part 2 of the update process, like at the initial installation.
The updater has finished
The updater has finished
Continue the update in the web interface
Continue the update in the web interface

Also this process can take some time. A message indicates the finished task. You also see if an which apps got deactivated.

Update running
Update running

Update finnished
Update finnished

 

After updating NC

 

  1. Reload the page and you’ll see the usual web interface.
  2. Check the version number in the admin area to get sure if the update was successful. You’ll also see errors and warnings if there are any.
  3. The next step is to activate the deactivated app again.
  4. If you are sure that everything is OK, it’s time to apply stricter permissions again. If you have already created this script by following the article about optimization, you could skip this step. Otherwise create a new script containing the following lines:
  5. Execute the script by entering sh /volumeX/Pfad/zum/Script.sh in putty.

    Fixed permissions
    Fixed permissions

That’s it, your Nextcloud is up-to date and ready for use again. I really recommend to create those two scripts. You’ll save some time and don’t have to look up for the correct permissions and apply them line by line in putty or set them in WinSCP, every time you want to update NC.

With the 3 articles about installation, optimization and updating of Nextcloud, you now have all the tools you need for setting up and maintaining Nextcloud on your Diskstation. But this is not the end of this article series, there are lots of things you can do with Nextcloud on you DiskStaion. I’ll continue after a short winter break.

 

Your own Cloud: Nextcloud on a Synology DiskStation

Leave a Reply

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