Unable to update to 21.0.1 "Create Backup" error

Hi all

Cannot upgrade through browser updater, keeps stopping at “Create Backup”

Current working setup:
NC21.0.0
Ubuntu20LTS
Nginx 1.18
Mysql8
PHP8
Redis
Data folder located @ /mnt/nextcloud/

Changed permissions chown -R www-data:www-data /mnt/nextcloud/

Trying to upgrade to 21.0.1.

EDIT: I just tried “sudo -u www-data php occ upgrade” and it says that “Nextcloud is already latest version”? Now I am baffled

you may try this command from a terminal on your NC Server

sudo -u www-data php updater/updater.phar

after upgrade has finished, you can complete with

sudo -u www-data php /location-of-your-nextcloud/occ upgrade

don’t forget to update columns and indices of your database.

1 Like

Hi I am getting errors:

root@webserv:/var/www/nextcloud# sudo -u www-data php updater/updater.phar
Nextcloud Updater - version: v20.0.0beta4-11-g68fa0d4

Current version is 21.0.0.

Update to Nextcloud 21.0.1 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-21.0.1.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 ...PHP Warning:  copy(/var/www/nextcloud/config/config.php.bak): Failed to open stream: Permission denied in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 395
[✘] Create backup failed
Could not copy "/var/www/nextcloud/config/config.php.bak" to "/mnt/nextcloud/updater-ocgy2wtg640w/backups/nextcloud-21.0.0.18-1619406940/config/config.php.bak". Source /var/www/nextcloud/config/config.php.bak is not readable. Destination /mnt/nextcloud/updater-ocgy2wtg640w/backups/nextcloud-21.0.0.18-1619406940/config/config.php.bak is not writable

Update failed. To resume or retry just execute the updater again.
root@webserv:/var/www/nextcloud# 

How do I get around this?
Thank you for your help

Failed to open stream: Permission denied in

So, before you start your update, have you checked your directory permissions of nextcloud folders?
For the updater to work i ususally set my folders beneath /var/www/nextcloud
chown -R www-data:www-data so that the updater is owner of the files that have to be overwritten.

Maybe your data folder also should be in ownership of your www user → check were you have placed your data folder in config.php.

The backups will be placed in a subfolder of your data folder, so it looks like your data folder is not writable by your www user in the moment when the updater starts the backup.

→ /mnt/nextcloud/…

check sudo su - and after that ls -la /mnt/nextcloud/... if all folders are owned by www user (www-data)

if there is one folder not in ownership of www-data:www-data then retry

sudo chown -R www-data:www-data /mnt/nextcloud

That will set recursive (incl. subfolders) every folder and file in ownership to www-data

after that retry the updater …

2 Likes

Great News Thank you, that worked…

and don’t forget to re-secure your installation!

https://docs.nextcloud.com/server/21/admin_manual/maintenance/manual_upgrade.html

mine problem was in file config.php.back owned by root so updater was unable to make backup of config file, after taken ownership of this file to www-data it update worked.

4 Likes

Perfect, thansk you

worked for me !

Magic!!! Thank you!

sorry that i get this thread out of death, but i updated my nextcloud with this commands (i had some errors with permission and wanna ask how to “update columns and indicies” proberly. Can you help me with this please? otherwise the update works now for me. Perfect

occ commands for columns, indices and primary-keys are here

sudo -u www-data php occ db:add-missing-indices
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#database-add-indices-label

sudo -u www-data php occ db:add-missing-columns

and

sudo -u www-data php occ db:add-missing-primary-keys

This what you thinking of?

yes you wrote “dont forget to update columnes and indices”

But with

it says "
Command “db:add-primary-keys” is not defined.

Did you mean one of these?
db:add-missing-columns
db:add-missing-indices
db:add-missing-primary-keys
db:convert-filecache-bigint
db:convert-mysql-charset
db:convert-type

"

mhm interesting. why. its a normal installation

my mistake, i added the “missing” in post above.

A list of all valid occ comands can be obtained by

sudo -u www-data php /var/www/nextcloud/occ

(in case that www-data is your webserver user and /var/www/nextcloud is your NC root dir)

works like a charm! Thanks Chrissi55

1 Like