Can't Upgrade via built-in updater due to "Can't Create Backup" step

Hello, I am having trouble updating Nextcloud from v21.0.5 to latest v 22.2.0. When I go to the web updater, Nextcloud can’t Create Backup and so it stops there.
I re-tried the update several times and nothing.

image

The only thing different I’ve done recently was that I moved the data folder from /var/www/nextcloud-data/ to a mounted drive in /mnt/nextcloud-data/ which is a network drive on my NAS. I had to mess with the /etc/fstab file in order automount this drive into this mountpoint, which included adding the following options uid=www-data,gid=www-data,file_mode=0770,dir_mode=0770.

Aside from that, I see in the /var/www/log/apache2/nextcloud.error file says something about Permission denied in /var/www/nextcloud/updater/index.php on line 529. When I look at line 529 of that file all it says is:

$state = copy($fileInfo->getRealPath(), $backupFolderLocation . $fileName);

When looking at this link https://docs.nextcloud.com/server/latest/admin_manual/maintenance/update.html I see that
Create backup: creates a backup of the existing code base in /updater-INSTANCEID/backups/nextcloud-CURRENTVERSION/ inside of the data directory (this does not contain the /data directory nor the database).

I opened the updater.log in /mnt/nextcloud-data/updater.log and I see the following lines:

2021-10-11T17:02:14-0400 TQBpiTnQj7 [error] POST request failed with other exception
2021-10-11T17:02:14-0400 TQBpiTnQj7 [error] Exception: Exception
Message: Could not copy "/var/www/nextcloud/config/config.php.bak" to "/mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak". Source /var/www/nextcloud/config/config.php.bak is not readable. Destination /mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak is not writable
Code:0

So it seems this in fact is some sort of permissions problem which I don’t know how to fix.

I don’t understand why it would say that:
Source /var/www/nextcloud/config/config.php.bak is not readable.

The next statement:
Destination /mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak is not writable
is more likely since this is the mounted network share, although permissions do show www-data with access, since I included the options in the fstab file for uid=www-data,gid=www-data,file_mode=0770,dir_mode=0770.

Another odd thing is that since I moved the data folder to the mounted one at /mnt/nextcloud-data, I am unable to sudo cd /mnt/nextcloud-data. When I try that I get sudo: cd: command not found.

Thank you for any help.

Nextcloud version (eg, 20.0.5): 21.0.5
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.3 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41 (Ubuntu)
PHP version (eg, 7.4): 7.4.3

The issue you are facing: Nextcloud can’t ‘Create Backup’ when trying to update to Nextcloud 22.2.0

Is this the first time you’ve seen this error? (Y/N): YES

Steps to replicate it:

  1. Login to web interface as administrator
  2. Go to settings - overview and ‘Open Updater’
  3. Click ‘Start update’

The output of your Nextcloud log in Admin > Logging:

Couldn't find anything relevant here

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

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxx',
  'secret' => 'xxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.example.com',
  ),
  'datadirectory' => '/mnt/nextcloud-data/',
  'dbtype' => 'mysql',
  'version' => '21.0.5.1',
  'overwrite.cli.url' => 'https://nextcloud.example.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'dbuser',
  'dbpassword' => 'dbuserpass',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'pipe',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'example.com',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'xxxxxxxxxx',
  'mail_smtpport' => '1025',
  'mail_smtpname' => 'nextcloud@example.com',
  'mail_smtppassword' => 'xxxxxxxxxx',
  'mail_smtptimeout' => 30,
  'remember_login_cookie_lifetime' => 1296000,
  'session_lifetime' => 2700,
  'session_keepalive' => false,
  'auto_logout' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'xxxxxxxxxx',
    'port' => 6379,
  ),
  'maintenance' => false,
  'updater.release.channel' => 'stable',
  'theme' => '',
  'loglevel' => 2,
  'default_phone_region' => 'US',
  'trashbin_retention_obligation' => 'auto, 30',
  'updater.secret' => 'xxxxxxxxxx',
);

The output of your Apache/nginx/system log in /var/log/____:

This is the output of /var/www/log/apache2/nextcloud.error:

[Mon Oct 11 14:55:35.303985 2021] [proxy_fcgi:error] [pid 540034:tid 140024037234432] [client 192.168.XXX.XXX:52726] AH01071: Got error 'PHP message: PHP Warning:  copy(/var/www/nextcloud/config/config.php.bak): failed to open stream: Permission denied in /var/www/nextcloud/updater/index.php on line 529'

I opened the updater.log in /mnt/nextcloud-data/updater.log and I see the following lines

2021-10-11T17:02:14-0400 TQBpiTnQj7 [error] POST request failed with other exception
2021-10-11T17:02:14-0400 TQBpiTnQj7 [error] Exception: Exception
Message: Could not copy "/var/www/nextcloud/config/config.php.bak" to "/mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak". Source /var/www/nextcloud/config/config.php.bak is not readable. Destination /mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak is not writable
Code:0

So it seems this in fact is some sort of permissions problem which I don’t know how to fix.

I don’t understand why it would say that:
Source /var/www/nextcloud/config/config.php.bak is not readable.

The next statement:
Destination /mnt/nextcloud-data/updater-ocxx0ed04fpq/backups/nextcloud-21.0.5.1-1633986115/config/config.php.bak is not writable
is more likely since this is the mounted network share, although permissions do show www-data with access, since I included the options in the fstab file for uid=www-data,gid=www-data,file_mode=0770,dir_mode=0770.

Another odd thing is that since I moved the data folder to the mounted one at /mnt/nextcloud-data, I am unable to sudo cd /mnt/nextcloud-data. When I try that I get sudo: cd: command not found.

Please learn all about sudo
The command is useless.

If you are root you can use the command without sudo.
You need sudo:
a.) execute command for e.g. www-data from e.g. root with with sudo -u www-data
b.) change from normal user e.g. to root: sudo -s

I got this today after having upgraded my RPi4B running my Instance of NC from “Buster 10/64” to “Bullseye 11/64” .

Running “sudo chown -R www-data:www-data /var/www/nextcloud/” resolved it for me.