Upgrading Nextcloud via CLI



  • The built in Nextcloud GUI updater works decent. But even their documentation says to use the CLI updater for larger installs to prevent timeout issues.

    Since version 15 finally was available in the stable channel a while back I made a guide while I was performing the update.

    For the purposes of this guide, we are going to assume that you are running Nextcloud version 12+ and you are running it on Fedora.

    Log in to the command line and switch to the root user

    sudo su -
    

    Disable SELinux temporarily

    setenforce 0
    

    Change to the Nextcloud directory appropriate to the install

    # default location
    cd /var/www/html/nextcloud
    

    Put Nextcloud in maintenance mode

    sudo -u apache php occ maintenance:mode --on
    

    Make a snapshot of your VM

    I always make the snapshot at this point because once it is in maintenance mode, no new changes will be accepted.
    So if things go to hell and you need to revert, there will be no conflict files.

    Run the updater.

    sudo -u apache php updater/updater.phar
    

    It will display this for an update

    c3c613f7-a546-4aa7-8af8-c3caab2de351-image.png

    Answer yes and it will perform the update.

    2238abaf-0ae0-413c-8f98-0d8b58bd07f0-image.png

    Tell it no when asked to run the occ upgrade command.

    I have had issue with answering yes this step in the past and just never let tit do it anymore. Someday, when I have free time, I will test this out again.
    c7dec9b0-436c-4ed0-8219-d6d6ca875157-image.png

    Run the occ upgrade command.

    sudo -u apache php occ upgrade
    

    d9ed39b4-e9c2-4dbd-8b11-4bf0fcc660af-image.png
    42925345-bfdc-4039-b847-22ae3bb8572a-image.png

    Turn maintenance mode back off.

    sudo -u apache php occ maintenance:mode --off
    

    Turn SELinux back on.

    setenforce 1
    

    Exit from the root user.

    exit
    

    Verify the update is successfully reflected in the web interface

    1e739674-8175-41e2-9310-87d2bbcff8cf-image.png

    Perform any follow up tasks now listed in the warnings section.

    8577e4c1-23fd-404c-96c7-47911f387f9e-image.png



  • @JaredBusch said in Upgrading Nextcloud via CLI:

    Make a snapshot of your VM
    I always make the snapshot at this point because once it is in maintenance mode, no new changes will be accepted.
    So if things go to hell and you need to revert, there will be no conflict files.

    Do you create a snapshot while the VM is powered on or off before upgrading Nextcloud?



  • I can't speak for @JaredBusch , but I usually take mine with the VM powered on.



  • @black3dynamite said in Upgrading Nextcloud via CLI:

    @JaredBusch said in Upgrading Nextcloud via CLI:

    Make a snapshot of your VM
    I always make the snapshot at this point because once it is in maintenance mode, no new changes will be accepted.
    So if things go to hell and you need to revert, there will be no conflict files.

    Do you create a snapshot while the VM is powered on or off before upgrading Nextcloud?

    Generally powered on. If it is a super critical need, I will shut it down.



  • @JaredBusch said in Upgrading Nextcloud via CLI:

    @black3dynamite said in Upgrading Nextcloud via CLI:

    @JaredBusch said in Upgrading Nextcloud via CLI:

    Make a snapshot of your VM
    I always make the snapshot at this point because once it is in maintenance mode, no new changes will be accepted.
    So if things go to hell and you need to revert, there will be no conflict files.

    Do you create a snapshot while the VM is powered on or off before upgrading Nextcloud?

    Generally powered on. If it is a super critical need, I will shut it down.

    Do you snapshot the memory too?



  • @pmoncho said in Upgrading Nextcloud via CLI:

    @JaredBusch said in Upgrading Nextcloud via CLI:

    @black3dynamite said in Upgrading Nextcloud via CLI:

    @JaredBusch said in Upgrading Nextcloud via CLI:

    Make a snapshot of your VM
    I always make the snapshot at this point because once it is in maintenance mode, no new changes will be accepted.
    So if things go to hell and you need to revert, there will be no conflict files.

    Do you create a snapshot while the VM is powered on or off before upgrading Nextcloud?

    Generally powered on. If it is a super critical need, I will shut it down.

    Do you snapshot the memory too?

    Why do you people always over complicate things?

    You pop your host and click make snapshot. Done.



  • @JaredBusch Do you turn off SELinux as a precaution or do you actively have problems while trying to update with it on?

    I'm curious because I followed your install guide and I've never turned it off to update and haven't had problems yet.



  • @bnrstnr said in Upgrading Nextcloud via CLI:

    @JaredBusch Do you turn off SELinux as a precaution or do you actively have problems while trying to update with it on?

    I'm curious because I followed your install guide and I've never turned it off to update and haven't had problems yet.

    If you followed my guide, most of the folders do not have HTTPD_RW. I tried without turning it off on the last 14.x to 14.x update and it failed on the precheck for write permissions.

    If you change the entire folder to HTTPD_RW it will work without disabling things.



  • @JaredBusch said in Upgrading Nextcloud via CLI:

    If you change the entire folder to HTTPD_RW it will work without disabling things.

    Ah yeah, probably this. SELinux is a complete mystery to me 🤷♂



  • @bnrstnr said in Upgrading Nextcloud via CLI:

    @JaredBusch said in Upgrading Nextcloud via CLI:

    If you change the entire folder to HTTPD_RW it will work without disabling things.

    Ah yeah, probably this. SELinux is a complete mystery to me 🤷♂

    ls -lashZ /var/www/html Will show you the context on your Nextcloud folder. Technically, just the Z is for the context