[SOLVED] Unable to upgrade 17.0.3 to 17.0.4 using the updater

Nextcloud version (eg, 12.0.2): 17.0.3
Operating system and version (eg, Ubuntu 17.04): Raspbian GNU/Linux 10 (buster)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.38 (Raspbian)
PHP version (eg, 7.1):7.3.14-1~deb10u1

The issue you are facing:
I tried to upgrade to 17.0.4 with the included updater but am getting
the following error:
Could not copy "/var/www/html/nextcloud/config/config.php~" to "/var/nextcloud/data/updater-ocqh8k0dgbes/backups/nextcloud-17.0.3.1/config/config.php~". Source /var/www/html/nextcloud/config/config.php~ is not readable. Destination /var/nextcloud/data/updater-ocqh8k0dgbes/backups/nextcloud-17.0.3.1/config/config.php~ is not writable
while I get:

total 56
-rw-r--r-- 1 www-data www-data  1270 Mar 14 18:12 config.php
-rw-r--r-- 1 www-data www-data 52964 Mar 14 18:12 config.sample.php```



Is this the first time you've seen this error? _(Y/N)_: today

Steps to replicate it:

1. Current version is 17.0.3.
Update to Nextcloud 17.0.4 available. (channel: "stable")
2. Run updater from admin interface
3. 

The output of your Nextcloud log in **Admin > Logging**:

Could not copy “/var/www/html/nextcloud/config/config.php~” to “/var/nextcloud/data/updater-ocqh8k0dgbes/backups/nextcloud-17.0.3.1/config/config.php~”. Source /var/www/html/nextcloud/config/config.php~ is not readable. Destination /var/nextcloud/data/updater-ocqh8k0dgbes/backups/nextcloud-17.0.3.1/config/config.php~ is not writable


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

cat /var/www/html/nextcloud/config/config.php

<?php $CONFIG = array ( 'instanceid' => '***', 'passwordsalt' => '***', 'secret' => '***', 'trusted_domains' => array ( 0 => 'raspi', 1 => '192.168.1.198', 2 => '***', ), 'datadirectory' => '/var/nextcloud/data', 'dbtype' => 'sqlite3', 'version' => '17.0.3.1', 'overwrite.cli.url' => '***', 'installed' => true, 'maintenance' => false, 'updater.secret' => '***', 'theme' => '', 'loglevel' => 0, 'mail_from_address' => '***', 'mail_smtpmode' => 'smtp', 'mail_sendmailmode' => 'smtp', 'mail_domain' => '***', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtpauth' => 1, 'mail_smtphost' => '***', 'mail_smtpport' => '465', 'mail_smtpsecure' => 'ssl', 'mail_smtpname' => '***', 'mail_smtppassword' => '***', 'onlyoffice' => array ( 'verify_peer_off' => true, ), 'app_install_overwrite' => array ( 0 => 'twofactor_rcdevsopenotp', ), 'twofactor_enforced' => 'true', 'twofactor_enforced_groups' => array ( ), 'twofactor_enforced_excluded_groups' => array ( ), ); ``` The output of your Apache/nginx/system log in `/var/log/apache2/error.log`: ``` [Sat Mar 14 18:02:19.133619 2020] [php7:warn] [pid 1037] [client 192.168.1.1:34980] PHP Warning: copy(/var/www/html/nextcloud/config/config.php~): failed to open stream: Permission denied in /var/www/html/nextcloud/updater/index.php on line 515, referer: https://stdcerr.duckdns.org/nextcloud/updater/ ```

The webserver user (www-data) must have permissions on the whole config/ directory, not just the config.php and config.sample.php files.

The problem was that /config/config.php~ didn’t have the correct permissions (root was the owner). chown-ing that file made the update go through properly!