Cannot Upgrade - Error Extracting

Nextcloud version (eg, 20.0.5): 20.0.2
Operating system and version (eg, Ubuntu 20.04): Raspbian buster
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.38 (Raspbian)
PHP version (eg, 7.4): PHP 7.3.27-1~deb10u1

The issue you are facing:
I’ve had to manually update as I get an error everytime I try to user the updater. I’d like to sort out how to resolve this. Please let me know what else I can do to help troubleshoot.

Is this the first time you’ve seen this error? No

Steps to replicate it:

  • Run the updater

The output of your Nextcloud log in Admin > Logging:

Nothing in there in the past few days.

updater.log

2021-02-21T22:23:43-0500 qRhFOkved5 [info] request to updater
2021-02-21T22:23:43-0500 qRhFOkved5 [info] currentStep()
2021-02-21T22:23:43-0500 qRhFOkved5 [info] Step 4 is in state "end".
2021-02-21T22:23:43-0500 qRhFOkved5 [info] POST request for step "5"
2021-02-21T22:23:43-0500 qRhFOkved5 [info] startStep("5")
2021-02-21T22:23:43-0500 qRhFOkved5 [info] verifyIntegrity()
2021-02-21T22:23:43-0500 qRhFOkved5 [info] getUpdateServerResponse()
2021-02-21T22:23:43-0500 qRhFOkved5 [info] updaterServer: https://updates.nextcloud.com/updater_server/
2021-02-21T22:23:43-0500 qRhFOkved5 [info] releaseChannel: stable
2021-02-21T22:23:43-0500 qRhFOkved5 [info] internal version: 20.0.2.2
2021-02-21T22:23:43-0500 qRhFOkved5 [info] updateURL: https://updates.nextcloud.com/updater_server/?version=20x0x2x2xxxstablexx2020-11-18T19%3A48%3A25%2B00%3A00+96f99a40f5569936f1951f1ccef8ea5fa25b607bx7x3x27
2021-02-21T22:23:45-0500 qRhFOkved5 [info] getUpdateServerResponse response: Array
(
    [version] => 20.0.7.1
    [versionstring] => Nextcloud 20.0.7
    [url] => https://download.nextcloud.com/server/releases/nextcloud-20.0.7.zip
    [web] => https://docs.nextcloud.com/server/20/admin_manual/maintenance/upgrade.html
    [changes] => https://updates.nextcloud.com/changelog_server/?version=20.0.7
    [autoupdater] => 1
    [eol] => 0
    [signature] => nc85F61OOmL3+Owiv7imtuQF1VxLCdZQtmIEwdKfMqXjBgrUkcfyJVJZd4BmNYKE
QiygnEEavOkDEGS7qoSNzl/HKcE6DknE0/5dGak6He1kK4ycOzSrNciysG2BXU6c
n/8S/PprAvCVdsHDiMgk/3ICvqBlxzRl5MxUGfXYID5UI0V1N5JNMXcCk5yDIZZJ
vb5gmUaRREraXFWSPaUXi8SSFVydELeJcx/wT2MNUsByOQnph2lP9tJUZxJMqeyU
M6oTzy4JLDpM1yA4BvarmcJLj9D5sRcIcM97VELTV5xc24Z9q8wZ2lVc1GemWyYa
sooIXtVt1YFaMbC9UegDoA==
)

2021-02-21T22:23:45-0500 qRhFOkved5 [info] storage location: /var/nextcloud/data/updater-ocm1lc7m2ppv/downloads/
2021-02-21T22:23:47-0500 qRhFOkved5 [info] end of verifyIntegrity()
2021-02-21T22:23:47-0500 qRhFOkved5 [info] endStep("5")
2021-02-21T22:23:47-0500 7c1zPB554V [info] request to updater
2021-02-21T22:23:47-0500 7c1zPB554V [info] currentStep()
2021-02-21T22:23:47-0500 7c1zPB554V [info] Step 5 is in state "end".
2021-02-21T22:23:47-0500 7c1zPB554V [info] POST request for step "6"
2021-02-21T22:23:47-0500 7c1zPB554V [info] startStep("6")
2021-02-21T22:23:47-0500 7c1zPB554V [info] extractDownload()
2021-02-21T22:23:47-0500 7c1zPB554V [info] storage location: /var/nextcloud/data/updater-ocm1lc7m2ppv/downloads/
2021-02-21T22:23:47-0500 7c1zPB554V [error] POST request failed with other exception
2021-02-21T22:23:47-0500 7c1zPB554V [error] Exception: Exception
Message: Can't handle ZIP file. Error code is: 5
Code:0
Trace:
#0 /var/www/html/nextcloud/updater/index.php(1354): Updater->extractDownload()
#1 {main}
File:/var/www/html/nextcloud/updater/index.php
Line:807

2021-02-21T22:23:47-0500 7c1zPB554V [info] rollbackChanges("6")
2021-02-21T22:23:47-0500 7c1zPB554V [info] unlink .step
2021-02-21T22:23:47-0500 7c1zPB554V [info] end of  rollbackChanges()

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '<removed>',
  'passwordsalt' => '<removed>',
  'secret' => '<removed>',
  'trusted_domains' => 
  array (
    0 => '192.168.100.200',
    1 => 'nextcloud.local',
    2 => 'nextcloud.mydomain.com',
  ),
  'datadirectory' => '/var/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.2.2',
  'overwrite.cli.url' => 'http://192.168.100.200/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_snuffy2',
  'dbpassword' => '<removed>',
  'installed' => true,
  'loglevel' => 2,
  'maintenance' => false,
  'allow_local_remote_servers' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0,
    'password' => '',
    'dbindex' => 0,
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'smtp.mydomain.com',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '465',
  'mail_smtpname' => 'nextcloud@mycomain.com',
  'mail_smtppassword' => '<removed>',
  'mail_smtpsecure' => 'ssl',
  'mail_domain' => 'mydomain.com',
  'mail_from_address' => 'nextcloud',
  'app_install_overwrite' => 
  array (
    0 => 'twofactor_email',
  ),
  'encryption.legacy_format_support' => false,
  'encryption.key_storage_migrated' => false,
  'updater.secret' => '<removed>',
);

The output of your Apache access.log:

xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:22:43 -0500] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 304 309 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:02 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:02 -0500] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 304 3485 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:02 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 1110 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:23:12 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 4288 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:23:12 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 1110 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:23:13 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 1119 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:14 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 4288 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:32 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:32 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 1110 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - - [21/Feb/2021:22:21:05 -0500] "POST /updater/index.php HTTP/1.1" 200 530 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:23:43 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 4286 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:23:43 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 1119 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:23:46 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 4288 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - - [21/Feb/2021:22:23:43 -0500] "POST /updater/index.php HTTP/1.1" 200 530 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0"
xx.xx.xx.xx - - [21/Feb/2021:22:23:47 -0500] "POST /updater/index.php HTTP/1.1" 500 567 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:02 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:02 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 1110 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"184.170.167.146
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:13 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:15 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 1112 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:18 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 4288 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:18 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 130760 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:25 -0500] "PUT /remote.php/dav/files/snuffy2/Documents/Screenshots/2021-02-21_22-24-04.611.png HTTP/1.1" 201 998 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:32 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:34 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 1109 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:37 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents HTTP/1.1" 207 130777 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:43 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Work%20Documents HTTP/1.1" 207 4295 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
yy.yy.yy.yy - snuffy2 [21/Feb/2021:22:24:43 -0500] "PROPFIND /remote.php/dav/files/snuffy2/Documents/Screenshots HTTP/1.1" 207 52043 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"
xx.xx.xx.xx - snuffy2 [21/Feb/2021:22:24:47 -0500] "PROPFIND /remote.php/dav/files/snuffy2/ HTTP/1.1" 207 1114 "-" "Mozilla/5.0 (Macintosh) mirall/3.1.2git (build 4615) (Nextcloud)"

Apache error.log

Nothing in there during the time the upgrade was running

ls of the update folder:

root@nextcloud:/var/nextcloud/data/updater-ocm1lc7m2ppv/downloads# ls -al
total 126388
drwxr-x--- 2 www-data www-data      4096 Feb 21 22:21 .
drwxr-xr-x 4 www-data www-data      4096 Feb 21 22:23 ..
-rw-r--r-- 1 www-data www-data 129412843 Feb 21 22:23 nextcloud-20.0.7.zip

Same error when updating from command line:

pi@nextcloud:~ $ sudo -u www-data php /var/www/html/nextcloud/updater/updater.phar
Nextcloud Updater - version: v20.0.0beta4-11-g68fa0d4

Current version is 20.0.2.

Update to Nextcloud 20.0.7 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-20.0.7.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

Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.

[✔] Check for expected files
[✔] Check for write permissions
[✔] Create backup
[✔] Downloading
[✔] Verify integrity
[✘] Extracting failed
Can't handle ZIP file. Error code is: 5

Update failed. To resume or retry just execute the updater again.

have you checked if there’s something like php-zip that might not be installed, yet?

Yeah, I have. Anything else?

pi@nextcloud:~ $ sudo apt install php-zip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php-zip is already the newest version (2:7.3+69).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

The Nextcloud update servers are a holy mess the last few days.
This always happens with a major release (v.21 this time)…

Wait a week…

I’ll wait a week and try again but unfortunately this has been happening for the last 6+ months. I’ve had to manually install every update I’ve done.

That sounds a bit strange…
I never had this problem when outside the release window.

Maybe you should check your storage for bad (failing) sectors?
It fails extracting, not downloading/verifying…

Or maybe you are just unlucky…:slight_smile:

I still couldn’t get this fixed so I wrote my own upgrade script cobbled together from other scripts and functions I’ve written or found. Use if this helps you but at your own risk.

#!/bin/bash
APP_NAME=Nextcloud
SERVICE_NAME=apache2
SERVICE_USERNAME=www-data
SERVICE_GROUP=www-data
DOWNLOAD=latest.zip
APP_URL=https://download.nextcloud.com/server/releases/latest.zip
SERVICE_LOC=/var/www/html/nextcloud
WORKING_DIR=/var/www/html

DBSERVER=localhost
DBNAME=nextcloud
DBUSER=oc_user
DBPASSWORD=password

# Privileges check
if [ "$EUID" -ne 0 ]; then
	echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [WARNING] Not running as root. You must have your sudoers file configured correctly."
	exit 1
fi

cd $SERVICE_LOC
CURRENT_VER=$(sudo -u $SERVICE_USERNAME php occ -V | sed 's/.*Nextcloud //g')
LATEST_VER=$(curl -SsL https://github.com/nextcloud/server/releases | awk '/\/tag\//' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | sed s/v//g)

vercomp () {
    if [[ $1 == $2 ]]
    then
        return 0 # eq
    fi
    local IFS=.
    local i ver1=($1) ver2=($2)
    # fill empty fields in ver1 with zeros
    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
    do
        ver1[i]=0
    done
    for ((i=0; i<${#ver1[@]}; i++))
    do
        if [[ -z ${ver2[i]} ]]
        then
            # fill empty fields in ver2 with zeros
            ver2[i]=0
        fi
        if ((10#${ver1[i]} > 10#${ver2[i]}))
        then
            return 1 # gt
        fi
        if ((10#${ver1[i]} < 10#${ver2[i]}))
        then
            return 2 # lt
        fi
    done
    return 0 # eq
}

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Current Version: $CURRENT_VER"
echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Latest Version: $LATEST_VER"

vercomp $CURRENT_VER $LATEST_VER
if [ $? -eq 2 ]
then
	echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Update Needed"
else
        echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] No Update Needed"
        exit 0
fi

echo  "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Stopping $SERVICE_NAME"
systemctl stop $SERVICE_NAME
if [ $? = 1 ]; then
        echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [ERROR] User does not have the permission to control $SERVICE_NAME service"
        exit 1
fi

# Check to see if directory has a forward slash at the end and correct it
if [[ $WORKING_DIR = */ ]]; then
        WORKING_DIR=$(echo $WORKING_DIR | sed 's/.$//')
else
        WORKING_DIR=$WORKING_DIR
fi

# Check to see if directory has a forward slash at the end and correct it
if [[ $SERVICE_LOC = */ ]]; then
        SERVICE_LOC=$(echo $SERVICE_LOC | sed 's/.$//')
else
        SERVICE_LOC=$SERVICE_LOC
fi

BACKUP_DIR=$WORKING_DIR/${APP_NAME,,}.$(date +"%Y%m%d.%H%M%S")
TEMP_DIR=$WORKING_DIR/${APP_NAME,,}.new
DB_BACKUP=$BACKUP_DIR/${APP_NAME,,}-sqlbkp_$(date +"%Y%m%d").bak

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Creating temporary directory $TEMP_DIR"
mkdir $TEMP_DIR
cd $TEMP_DIR

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Downloading $APP_NAME"
wget -nv -nc $APP_URL

if [ $? -ne 0 ]; then
   echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [ERROR] Failed to download"
   exit 1
fi

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Extracting $DOWNLOAD"
unzip -oq $DOWNLOAD

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Backing up current $APP_NAME to $BACKUP_DIR"
mv $SERVICE_LOC $BACKUP_DIR

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Backing Up $APP_NAME Database to $DB_BACKUP"
mysqldump --single-transaction -h $DBSERVER -u $DBUSER -p$DBPASSWORD --result-file=$DB_BACKUP $DBNAME

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Moving new $APP_NAME"
mv $TEMP_DIR/${APP_NAME,,} $SERVICE_LOC

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Copying over config files from $BACKUP_DIR"
cp -f $BACKUP_DIR/config/config.php $SERVICE_LOC/config/

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Changing ownership to $SERVICE_USERNAME:$SERVICE_GROUP"
chown -R $SERVICE_USERNAME:$SERVICE_GROUP $SERVICE_LOC
chown -R $SERVICE_USERNAME:$SERVICE_GROUP $BACKUP_DIR

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Setting Permissions for $APP_NAME"
find $SERVICE_LOC/ -type d -exec chmod 750 {} \;
find $SERVICE_LOC/ -type f -exec chmod 640 {} \;

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Deleting $TEMP_DIR"
rm -rf $TEMP_DIR

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Starting $SERVICE_NAME"
systemctl start $SERVICE_NAME

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Upgrading $APP_NAME Database"
cd $SERVICE_LOC
sudo -u $SERVICE_USERNAME php occ -n upgrade

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Running Bigint Upgrade on $APP_NAME Database"
sudo -u $SERVICE_USERNAME php occ -n db:convert-filecache-bigint

echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] Adding Missing Indices on $APP_NAME Database"
sudo -u $SERVICE_USERNAME php occ -n db:add-missing-indices

cd $SERVICE_LOC
NEW_VER=$(sudo -u $SERVICE_USERNAME php occ -V | sed 's/.*Nextcloud //g')
echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") [INFO] $APP_NAME updated to $NEW_VER"
/home/pi/scripts/pushover.sh "$APP_NAME updated to $NEW_VER" -2