True-NAS jail: Update NextCloud using command line

In my opinion the best way to update NextCloud is using the command line, with the web installer I had some problems, especially if the internet connection is not really fast. Therefore I always use the command line to update NextCloud.

In this blog entry I will give a short tutorial how to update NextCloud to the latest version, using the command line of the jail. For this tutorial I will use the Shell of the TrueNAS web interface.

As first step I would suggest that you update your jail to the latest version. This is quite simple, you can directly do this in the web interface of TrueNAS. Login, go to “Jails” -> select the NextCloud jail -> Press the “>” icon in the right and select “Update”. A dialog will open where you need to confirm, and then the update is executed.

After this, select the shell of the jail.

To remember the default NextCloud jail of TrueNas is using the following installation/configuration settings/paths:

  • Webserver: NGINX
  • PHP: php-fpm
  • Path to NextCloud: /usr/local/www/nextcloud
  • User who is running nginx and PHP: www

With this information we will simply call the command line updater of NextCloud using the following command:

sudo -u www php /usr/local/www/nextcloud/updater/updater.phar

If the command is working and no error is thrown you should get the following output (I already pressed Y that I want to update NextCloud):

If you have a problem with the information that stopping the update using Ctrl-C is not possible, you can install the PCNTL extension using snap.

The Updater is now creating a backup, then its downloading the latest NextCloud release, after that it checks the integrity and certain other things. Dependent on the internet connection and the performance of your TrueNAS instance this can take a while.

When the update is successfully the systems asks the user if the occ upgrade command should be executed. This is necessary to finish the update. During this step changes in the database and the file data structure of NextCloud are executed and new versions of the plugins are installed.

Press “Y” to execute the occ upgrade. After a while everything should be finished and NextCloud asks you if the maintenance mode should stay active. Enter “N” and NextCloud should again be online.

The update is only executed from the running version to the next one and not to the latest! If there are several versions in between it can be necessary to execute the update command more than one time.

Print Friendly, PDF & Email


  1. I thought I found the perfect way to not break my update of nextcloud jail. But for some reason I was presented with no update found. And few error during the update. And then all I got was Internal server error. I had similar experience back when i spend days to find a solution and ultimately gave up and used snapshot to gain nextcloud back. Below command don’t even work after the internal server error webpage shows up.
    sudo -u www php /usr/local/www/nextcloud/updater/updater.phar

    Some msg that show up while updating was ‘ YES -> YES Getting CA Private Key fail2ban_enable: YES -> YES Getting CA Private Key Starting redis. Getting CA Private Key ERROR – Fail to run migrations. Getting CA Private Key ERROR – Fail to run migrations. /lib/ version FBSD_1.7 required by /usr/local/lib/ not found’

    1. Do you have problems with the nextcloud update, oder with the certificate. Your error messsages seams, that your problem belongs to the certificate?


  2. I struggle updating nextcloud almost every time. something or other break and i have to resort to rollback snapshot on truenas.
    your command sudo -u www php /usr/local/www/nextcloud/updater/updater.phar does not work on Truenas as it returns sudo: command not found. Can you revisit this guide.

    1. Hello, you do not have the sudo modul installed, therefore you get the error. You must install sudo using the following command: pkg install sudo


      1. When I try to run the updater even after the sudo pkg install, I receive this error:

        Fatal error: Uncaught Error: Class “Phar” not found in /usr/local/www/nextcloud/updater/updater.phar:10
        Stack trace:
        #0 {main}
        thrown in /usr/local/www/nextcloud/updater/updater.phar on line 10

        Any idea what might be causing this?

  3. I was able to update later. however, since then more updates have arrived and with a growing warning to update the php8 to a newer version. Do you have a tutorial how to achieve this as I tried multiple time and failed to update and i have to roll back to snapshot as it threw the server in internal error and other issues (probably not related to outdated php).

    1. I will try to have a look, what has changed and how to avoid any problems, when I have time. But in my opinion the future of TrueNAS will be the Scale version.

Leave a Reply

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