Nextcloud update via script

Hello,

I update my nextcloud installation via script:

sudo -u www-data php /var/www/nextcloud/updater/updater.phar -n

However, versions X.0.0 (e.g. 27.0.0) often still contain errors. That’s why I would like to update from X.0.1 (e.g. 27.0.1).

How would I have to change the script so that versions X.0.1 and higher are installed first?

Thank you!

Tony

That is not possible. The update is first to the latest version of the actual Nextcloud release. Today for Nextcloud 27 the version 27.1.8 will be shipped. Hopefully it works then If not post some errors.

Maintenance and Release Schedule · nextcloud/server Wiki · GitHub

Would there be a way to evaluate the output of

sudo -u www-data php /var/www/nextcloud/occ update:check ?

Depending on the output, the command

sudo -u www-data php /var/www/nextcloud/updater/updater.phar -n

could only be executed if it is NOT a version X.0.0.

Does anyone have an idea how I could do this as a bash script?

Thank you!

… this command provides information about various updates in a fairly conversational way, including whether an update is available for apps and not just about updates for the server core.
Parsing various data collected in different ways is one of the basic techniques that you should master if you want to write (Bash) scripts. This is not a Nextcloud-related topic but rather about learning Bash in general.
What I would like to advise you, however, is that if you are already having difficulties with this simple basic technique, then I would definitely not leave something as sensitive as updating your Nextcloud server, where so many things can go wrong, to a script. There should be a number of similar tests that must be carried out to check the status of the update, the results of which should then be used to make further decisions, such as a rollback or abort, etc.
After all, you don’t want your server to suddenly become unavailable, do you?


Much and good luck,
ernolf

I use the github api to access existing server versions and tags in a bash script.

Here is a function like I use it in → nc-apps ← , for example:

github_api(){
    local URL="https://api.github.com/repos/$1/$2?per_page=$3"
    case $2 in
          tags) curl -s "$URL" | jq -r '.[] | .name'     | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
                ;;
      releases) curl -s "$URL" | jq -r '.[] | .tag_name' | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
    esac
}

Here is a sample output:

root@box:~# github_api "nextcloud/server" "releases" "10"
29.0.0rc1
28.0.4
27.1.8
26.0.13

These results can now be easily parsed for patterns. You don’t even need any knowledge of regular expressions, as this version can be divided into numbers.
I can explain all of this to you, but I feel a little strange because it’s explaining a language and doesn’t really belong here.


But I don’t want to leave you out in the cold like that. Therefore, here is a hand-picked series of sources from which you can familiarize yourself with all the techniques of bash and shell scripting.

  1. Bash Documentation: The official Bash documentation is an excellent source for detailed information on Bash commands, syntax, and functions. It’s available at GNU Bash manual - GNU Project - Free Software Foundation.
  2. Bash Guide at TLDP: The Bash Guide on The Linux Documentation Project (TLDP) provides a comprehensive introduction to Bash programming along with many practical examples. You can access it at http://tldp.org/LDP/abs/html/.
  3. Bash Academy: An interactive online platform offering free courses on Bash programming. It provides a blend of lessons and hands-on exercises. Visit https://guide.bash.academy/.
  4. Shell Programming at Wikibooks: The Shell Programming book at Wikibooks offers a solid introduction to shell scripting with plenty of examples and explanations. You can read it at https://en.wikibooks.org/wiki/Bash_Scripting.
  5. Bash Scripting Cheat Sheet at Devhints: Devhints offers a handy Bash scripting cheat sheet containing quick references to commonly used commands and syntax. You can find it at Bash scripting cheatsheet.
  6. Bash Scripting Tutorial at ShellCheck: ShellCheck provides a tutorial on Bash scripting along with a handy shell script analysis tool to improve script quality. Access it at https://www.shellcheck.net/.
  7. Bash Scripting Guide at Ryanstutorials: Ryanstutorials offers a comprehensive guide to Bash scripting with step-by-step explanations and practical examples. Explore it at Bash Scripting Tutorial - Ryans Tutorials.

and last but not least, the source of most of my knowledge, the man pages:

apropos . | xargs -n 1 man

Much and good luck,
ernolf

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.