Nextcloud 16/17 on OpenBSD 6.7: Update via command line
Tags: nextcloud, openbsd, update, commandline
Published: 2019-11-20 13:51:01

---
title: Nextcloud 16/17 on OpenBSD 6.7: Update via command line
published: true
description: NextCloud provides build-in updater. Thankfully, We can update/upgrade NextCloud with it. This post is about how to carry it out via command line after installing NextCloud on OpenBSD.
tags: nextcloud, openbsd, update, commandline
series: NextCloud on OpenBSD
canonical_url: https://obsd.solutions/en/blog/2019/11/20/nextcloud-16-17-on-openbsd-67-update-via-command-line/index.html
---

## Summary

[NextCloud](https://nextcloud.com/), "the flexible open source file synchronization and sharing solution",  provides [build-in updater](https://docs.nextcloud.com/server/stable/admin_manual/maintenance/update.html).
Thankfully, we can update/upgrade the software with its own updater.

### Updated on 2020-02-10

Updating 18.0.14 -> 19.0.8 and 19.0.8 -> 20.0.7 were successful with the web updater instead of command line interface on [OpenBSD](https://www.openbsd.org/) 6.8 with [PHP](https://www.php.net/) 7.4. It's more convenient : )

## Overview

This is how to carry it out via command line after installing NextCloud on [OpenBSD](https://www.openbsd.org/):

```console
# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php

$ cd <nextcloud-dir>

$ # apply for env without `chroot` to "datadirectory"
# nvim config/config.php

$ # `occ upgrade` in updater.phar requires `php` executable
$ doas -u <nextcloud-user> php updater/updater.phar
$ # Continue update? -> y
$ # Should the "occ upgrade" command be executed? -> y
$ # Keep maintenance mode active? -> y
$ # or:
$ #doas -u <nextcloud-user> php-7.3 occ maintenance:mode --off

$ # apply for env with `chroot` to "datadirectory"
$ doas nvim config/config.php

# rm /usr/local/bin/php
```

## Tutorial (Step-by-step description)

Move to the NextCloud directory:

```console
$ cd <nextcloud-dir>
```

First, change [`config.php`](https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html) temporarily:

```console
# nvim config/config.php
```

Here, set "datadirectory" as it is without [`chroot`](https://man.openbsd.org/chroot):

```diff
- 'datadirectory' => '/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/var/www/<web-dir>/nextcloud/data',
```

Next, prepare [`php`](http://php.net/) executable for `updater.phar`:

```console
# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php
```

OK. Ready.
Let's run updater:

```console
$ doas -u <nextcloud-user> php updater/updater.phar
```

The updating process will start like this:

```console
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 16.0.6.

Update to Nextcloud 17.0.1 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip
Open changelog ↗

Steps that will be executed:
[ ] Check for expected files
[ ] Check for write permissions
[ ] Create backup
[ ] Downloading
[ ] Verify integrity
[ ] Extracting
[ ] Enable maintenance mode
[ ] Replace entry points
[ ] Delete old files
[ ] Move new files in place
[ ] Done

Start update? [y/N] y
```

Then


```console
Info: Gracefully stopping the updater via Ctrl-C is not possible - PCNTL extension is not loaded.

[✔] Check for expected files
[✔] Check for write permissions
[✔] Create backup
[✔] Downloading
[✔] Verify integrity
[✔] Extracting
[✔] Enable maintenance modeconfig/
[✔] Replace entry points
[✔] Delete old files
[✔] Move new files in place
[✔] Done

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n] y
```

And

```console
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
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
2019-11-20T12:55:00+00:00 Set log level to debug
2019-11-20T12:55:00+00:00 Repair step: Repair MySQL collation
...
2019-11-20T12:56:37+00:00 Update successful
2019-11-20T12:56:37+00:00 Maintenance mode is kept active
2019-11-20T12:56:37+00:00 Reset log level

Keep maintenance mode active? [y/N] y
```

Maintenance mode is still necessary because we have an invalid `config.php` where `chroot` is deactivated.

```console
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
...
```

The update is successful.
Let's clean up and restart the service.

Remove the temporary executable:

```console
# rm /usr/local/bin/php
```

Stop maintenance mode:

```console
$ doas -u <nextcloud-user> php-7.3 occ maintenance:mode --off
```

Finally, restore "datadirectory" in `config.php` to be under `chroot`:

```console
# nvim config/config.php
```

```diff
- 'datadirectory' => '/etc/www/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/<web-dir>/nextcloud/data',
```

Finished.