What app is this about, and its version: Nextcloud 33.0.3~ynh1 What YunoHost version are you running: 12.1.40.1 What type of hardware are you using: Raspberry Pi 3, 4+
Describe your issue
Hello everyone,
I attempted to upgrade Nextcloud from 33.0.3~ynh1 to 33.0.4~ynh1 today but it looks like I ran out of disk space during the upgrade so that step failed. Yunohost then tried to reinstall the previous version from its backup but that failed too (because of the disk space issue).
My system now does not have Nextcloud anymore but it looks like its associated data is still there (under /home/yunohost.app/nextcloud). My issue is that I had planned on taking a full backup after the app upgrade; I can still do that but since Nextcloud is no more installed, the backup skips the Nextcloud data files. I have a backup available but it’s 15days old and I would like to get the app back up and running if possible first.
Could you tell me if, once the disk space issue is solved[1] I can safely reinstall Nextcloud (from its pre-upgrade backup) and it will use the existing data ?
Thanks for your help and for allowing a hassle-free hosting of apps !
Vincent
[1] My root FS lives on a 10 GiB partition of an external disk (/home is also there but on a much larger partition) and this is surely where the problem comes from. I am using ncdu to find some space to free up (looks like I have several old versions of node lying around, advice welcome for what to remove w/o issues).
It seems much safer to me to back up the data first
do you mean there is a way to still perform a data backup from within Yunohost or are you referring to backup up /home/yunohost.app/via a filesystem copy/backup ?
Data-wise in Nextcloud, I am interested in all the user files as well as the contacts and agendas. Is there a way to backup those in one swoop?
Restoring from pre-upgrade should be enough to get to where it was before the upgrade.
You can run yunohost tools basic-space-cleanup to make more space. You will need a little more than the double size of the pre-upgrade backup of free space to restore.
Check which node version you are using grep -r "node" /etc/yunohost/apps/*/settings.yml
Delete the unused versions
So after backing up the remaining Nextcloud data on a separate disk and searching for a way to backup the existing Nextcloud database (which, I learnt, is where the contacts and agendas are stored), I realized it was included in the pre-upgrade backup archive. So backups were good.
I proceeded to restore the app via the pre-upgrade backup and this step went well (cf https://paste.yunohost.org/raw/qibiqoqere). Nextcloud appears again in the app list and the UI.
It is however not functional, I have the following when accessing the Nextcloud page:
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
Fair point about the maintenance step being needed I thought, as you said. I thus proceeded to repair the app but I cannot run the occ shell. It fails with :
An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user 'nextcloud'@'localhost' (using password: YES) in /var/www/nextcloud/lib/private/DB/Connection.php:238
This looks like the problem several other users have encountered, for instance here or there or here. All of these requires pretty heavy mySQL surgery so I wanted to check with you first what to do.
Edit1: Also forgot to thank you @jarod5001 for the cleanup bits: I used the yunohost command you mentioned (saved 350 MiB) and found that none of the node installs were actually used by any of the apps I have installed (saved 1.5 GiB).
Edit2: looking into the mariaDB database, I also don’t see a user associated with nextcloud. This might be where the problem is coming from, no?
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
| sys |
| wallabag2 |
+--------------------+
MariaDB [(none)]> use nextcloud;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [nextcloud]> SHOW TABLES;
+-----------------------------+
| Tables_in_nextcloud |
+-----------------------------+
| oc_accounts |
| oc_accounts_data |
| oc_activity |
| oc_activity_mq |
| oc_addressbookchanges |
| oc_addressbooks |
| oc_appconfig |
| oc_appconfig_ex |
| oc_authorized_groups |
| oc_authtoken |
[...]
MariaDB [nextcloud]> SELECT host, user FROM mysql.user;
+-----------+-------------+
| Host | User |
+-----------+-------------+
| localhost | mariadb.sys |
| localhost | root |
| localhost | wallabag2 |
+-----------+-------------+
MariaDB [nextcloud]> SELECT User, Db, Host from mysql.db;
+-----------+-----------+-----------+
| User | Db | Host |
+-----------+-----------+-----------+
| wallabag2 | wallabag2 | localhost |
+-----------+-----------+-----------+
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'ZfGsognchgFLilOBFUSCATED';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
EXIT;
That was it, thanks @otm ! After recreating the nextcloud user, I could run the occ shell maintenance:repair command and I can access my Nextcloud web UI (and my files) again! Many big thanks to you and @jarod5001 for your timely help
I suspect the problem could indeed be what this post said:
ce qui me fait penser qu’il y a un quack dans le script d’upgrade de nextcloud quand ça plante. je pense que le script ne restore pas l’user nextcloud dans mariadb.
From what I can see in the Nextcloud YNH manifest, it does declare a mysql DB (which, from what I see is handled by the YNH core for creation and removal). However, the backup script DB step calls ynh_mysql_dump_dbwhich dumps only the app DB (and not the mysql.user DB containing the associated user. From thedb.sql backup file which I have from the pre-upgrade backup tar and which is restored by the associated script, I don’t see any CREATE USER statements, only things related to creating tables.
I might be wrong though since the core of YNH might handle these steps instead (as it does for installation/removal). Any clarifications welcome of course.
On a final note, would it help to add a mention in the YNH app doc that data is both in the MySQL DB (agendas, contacts) as well as the external user data? This would help people understand how backups are performed (I can submit a PR) …
Understood. I was actually referring to what can be found in the db.sql backup file, which appear to restore only the contents of the nextcloud database but not any associated user (via a CREATE USER statement).
Since user creation/deletion for an app declaring a DB in its manifest is handled by the core of YNH, I am not sure why the user was not recreated when the app was restored from its backup. As I guess the nextcloud user is deleted when the app is uninstalled, the user should be recreated when restoring Nextcloud from a backup, no?