Nextcloud update (and restore) failed after first updating yunohost

The backup restore process that got stuck on INSERT INTO memories_planet_geometry VALUES and you mentioned here Nextcloud update (and restore) failed after first updating yunohost - #22 by Daize

if you run the restore via the CLI then ctrl+C, if you tried via the webUI, I just went into the CLI and shut it down (sudo reboot)

1 Like

You shouldn’t do that. Upgrade script enables and disables it when needed. That’s what caused the upgrade issue :

2026-01-02 11:48:26,918: WARNING - Nextcloud is in maintenance mode, no apps are loaded.
2026-01-02 11:48:26,918: DEBUG - + ldap_config_prefix=
2026-01-02 11:48:26,920: WARNING - Commands provided by apps are unavailable.
1 Like

You have to remove this table (wrong prefix which should be oc_memories…)

odd, since in the documentation it seems to be the only table that doesn’t have that prefix Troubleshooting - Memories

oops, that’s right. I got confused. All others tables begin with oc_ which is nextcloud table prefix.

1 Like

thanks! This sounds quite delicate, you mean manually delete the lines following with those?

--
-- Table structure for table `memories_planet_geometry`
--

DROP TABLE IF EXISTS `memories_planet_geometry`;

There are more than 10k lines of INSERT INTO 'memories_planet_geometry' VALUES, or am I looking at the wrong part?

Yup, that’s a huge table… Removing it is a workaround, but the backup script may get stuck with the binary data from the geometry table.
You can also try this

you’re not reading it wrong, it’s pretty nuclear and I don’t like it. I do dislike not having my Nextcloud work more, though.

I also tried adding a try/except to the process.py file to use utf8mb4 when utf-8 didn’t work for restoring the database. However it did seem to add the memories_planet_geometry table with lots of rows, it did not finish restoring Nextcloud..

Removing the table from db.sql wasn’t that hard, thanks to otm33 & see How to Delete Line in Nano Editor? - GeeksforGeeks Method 2

1 Like

I think I managed to do all this, but when trying to restore the backup from the webadmin I get the error The following apps can't be restored because they are already installed: nextcloud

I think I’ve found a much less invasive solution: prevent displaying the database restore output in the logs; that way there’s no problem with decoding binary data.
=> Only necessary to edit the restore script.

cd /home/yunohost.backup/archives
tar xvf  nc_bak2.tar apps/nextcloud/settings/scripts/restore
nano apps/nextcloud/settings/scripts/restore

Edit this line
from

ynh_mysql_db_shell < ./db.sql

to

ynh_mysql_db_shell < ./db.sql > /tmp/nextcloud_restore.log 2>&1

Then

tar --update -f  nc_bak2.tar apps/nextcloud/settings/scripts/restore
yunohost backup restore bak2 --debug
2 Likes

thanks! but would it restore if nextcloud is already installed?

It’s a feature, so you don’t overwrite unintentionally. So if you want to restore a NC backup, first uninstall NC (if installed)

1 Like

When running tar --update -f I get the following:

tar: Cannot update compressed archives
tar: Error is not recoverable: exiting now

are you in the ā€œarchivesā€ folder ?

yes:

root@my-server:/home/yunohost.backup/archives# tar --update -f nextcloud-pre-upgrade2-original.tar apps/nextcloud/settings/scripts/restore
tar: Cannot update compressed archives
tar: Error is not recoverable: exiting now

It’s not a real tar archive (a tar.gz ?)

Maybe I got confused between the two. These are the files in the directory, should I have operated on the .tar.gz instead?

theadmin@my-server:/home/yunohost.backup/archives$ ls -la | grep nextcloud-pre-upgrade2
-rw-r--r-- 1 root       root                342 Jan  2 00:03 nextcloud-pre-upgrade2.info.json
lrwxrwxrwx 1 root       root                 60 Jan  2 00:03 nextcloud-pre-upgrade2.tar -> /home/yunohost.backup/archives/nextcloud-pre-upgrade2.tar.gz
-rw-r--r-- 1 root       root         3422776535 Jan  2 00:03 nextcloud-pre-upgrade2.tar.gz

nextcloud-pre-upgrade2.tar is a symlink to nextcloud-pre-upgrade2.tar.gz

So I cannot update it with tar --update -f ?