Use case:
What I want:
On top of that:
This is a very important feature because there are so many apps that come and go, sadly. A database/filesystem littered with old unused stuff that might create problems/conflicts with other apps/newer releases of Nextcloud is just not a great situation.
Aside from that, it would also get rid of mangling directly with the database if an app misbehaves and has to be restored to a "clean" state (i. e. removing everything related to the app in the database/file system).
Anyway, before deleting something, the admin should be asked and a backup should be created in the file system somewhere of any deleted data (creating a dump of the table and a tarball with the files that were deleted). So, in case something important was stored in it, this wouldn't be lost. The only other option would be to restore the whole old installation from a backup and start it up somewhere (a virtual machine?) and grab the data. This would be a lot of work if only a certain table would have been deleted for example.
Oh yes, this would be very nice. I use my Nextcloud since version 9 and I always updated it, tested this app and that app... I would like to clean up my Nextcloud, but I don't know how. Installing a fresh Nextcloud is no problem. Transferring files with rsync is also easy. But then I ran into problems, because I don't know which tables and files hold the users, the IDs, hashed passwords, contacts, calendar ... and so on. So a migration-tool or a cleanup-tool would be useful.
I tried using php occ db:convert-type
. In one of the github issues here and in the documentation I read that this command will skip some unneeded tables. But when I execute this command, it says, "cannot migrate from mysql to mysql".
So this command is only for migration vom sqlite to mysql.
Adding to this slightly (although is already known). The "oc_bruteforce_attempts" table appears to never be cleaned.
To keep this request alive, I would also love to see an ability to "purge" app data from database and data dir in case. Of course this requires a list of tables and files/dirs an app uses/creates.
I would vote for this as well.
During my support in Nextcloud forums I install many apps for testing and my db has a lot of garbage in it. Some tables I delete manually, with the risk to damage my system.
This definitely needs to be done - it's subpar that an app installed and removed years ago still has table in my DB.
Yes, that鈥檚 a fault in legacy packaging methods too.
yes, to be able to purge any app would be a great feature...!
some apps can be deleted via the web gui, but not all... this is very strange...
@phonon112358 Some apps are core apps and part of the installation. They cannot be uninstalled, just disabled.
@rakekniven yes, but I am talking about apps that I installed manually, e.g., default encryption module.
I have an app that disabled web browser access to nextcloud. I can only use cpanel to access the nextcloud files so i Renamed the app folder in order to gain access from web browser again. Can't remove the app now...
Suggestion on how to implement this concerning UX (I also need this, badly!):
Have there be a checkmark that can be set when uninstalling an App. Maybe not in the list overview, but in the detail view of the app. Or after clicking uninstall, ask whether or not any data corresponding to this app should be removed from the database and/or filesystem. There might even be an option for a backup of that bit? Maybe perform a dump, or have an extra part of the database for that.
As for old apps that once had been installed, there could also be an option that maybe says that this app has previously been installed, and is using database resources, do you wish to clean up the database.
Or have it as an extra step after deactivating an app, before being able to click delete, it would prompt for database cleanup for all the tables that app (and only that app) created. Or the other way around, after having deleted the app, that option becomes available.
And of course, a general check would be nice too - that could basically check against all apps that ever were on the app-store, check which tables they (would) have created, and then offer deletion of said tables. All with double and triple checks if need be.
I started when it was still owncloud 5, switched as soon as there was the first stable fork - and it is such a hassle to keep the database clean.
EDIT: even better yet - offer a "clean install" if database entries are detected that are from older installations - delete the database entries the app wants to install before it actually does install. that might be a good first step, before tackling a database cleanup that might damage the installation.
Additionally occ
CLI could get an app:purge
command, similar to apt-get remove
and apt-get purge
to remove attached userdata and database entries.
I think Nextcloud cannot know which app creates which files and database tables, does it? In case I think it requires some new app API, e.g. an array that developers can use to add database tables and directories below userdata to be removed when using the purge option. If this array does not exist (yet), e.g. because the developer did not (yet) implement it or the app does not create anything such, the purge option could be hidden (to avoid confusion) or simply left without effect (means that admins might complain that the purge option left app-related stuff in place).
I think Nextcloud cannot know which app creates which files and database tables, does it?
AFAIK it does, at least for current apps which follow the guidelines. At least for database tables, apps needing their own are (were?) supposed to ship a appinfo/database.xml
file defining its structures. Not sure if that's still the case, though: I've just checked on one of my installations, and found them missing from more recent apps I'm sure using their own tables.
Okay great, that makes it easier 馃憤.
I had to update nextcloud manually (replace all files), because of a bug I was not able to login to webgui anymore. But now some apps could be not updated together with nextcloud because there are no versions for 19.0.3 available e.g. files_rightclick. Now the installation says "The files of the app Right click (files_rightclick) were not replaced correctly. Make sure it is a version compatible with the server."
It would be cool to provide a method via occ to remove apps, so I don't have to use the webgui. Is this possible?
It would be cool to provide a method via occ to remove apps, so I don't have to use the webgui. Is this possible?
You can already do that, check out the full list by calling occ
without arguments and you'll find: occ app:remove
I think Nextcloud cannot know which app creates which files and database tables, does it?
AFAIK it does, at least for current apps which follow the guidelines. At least for database tables, apps needing their own are (were?) supposed to ship a
appinfo/database.xml
file defining its structures. Not sure if that's still the case, though: I've just checked on one of my installations, and found them missing from more recent apps I'm sure using their own tables.
Same here. Just tried to disable -> remove the news
app via the occ
and, to my surprise, it wasn't a "clean" removal at all, leaving three tables in the DB (oc_news_feeds
, oc_news_folders
, oc_news_items
). This isn't some kind of an obsolete app: it targets Nextcloud 20 and it also doesn't have database.xml
.
I couldn't find a single place describing all of those tables. It seems like it's not that easy to connect apps and tables, in general. Makes me wonder what else the remove
command might miss. Being able to do clean uninstalls is pretty important for certain use cases such as debugging and tweaking some apps. For instance, this news
app crashed my Nextcloud 20 upgrade process yesterday and the logs say that something went wrong with the schema migration. This problem might not disappear if those tables and their schema are simply ignored by this "removal".
Here's an idea on how to implement NC "knowing" which app installed which files and tables (no idea how feasible it is):
Let NC save the current names of tables, and whenever an app is installed - check which new tables have been added. Save those new tables as linked with the app that just got installed. Therefor it should then be able to know which tables to offer to delete when uninstalling the app.
I hope that makes sense.
NC saves a list of the tables
App gets installed - NC checks and compares tables, stores the new tables as corresponding to app
Admin uninstalls app - NC asks whether or not to remove corresponding DB-entries, deletes tables according to what it saved as the diff when the app got installed -- there should of course be a warning, that user data linked with this app will be lost and gone if the apps should be reinstalled at a later date - hence it should ask about wanting to delete those entries.
That same list could be used for a cleanup of the DB. Which in turn can have checkmarks, and let the admin know which app-data is still lingering around. Maybe a checkbox for each app that created its own tables could be usefull here too.
Similarly possible with files - but that could take a bit more resources from the server, since a filesystem-check like that could take quite a bit longer with the amount of files and folders maybe increasing (think preview-app, or office-apps).
It could also make it possible to offer a "clean database" feature. If NC knows its own tables, creates a diff after an update for example, it can then offer to "reset" the database to only have the base entries be untouched. Similarly with old entries from ages ago. There could even be a resource somewhere on the store page, where the changes to the DB by different apps get reported by the NC-Apps-Installer to.
That way, the apps wouldn't even need to bring a database.xml file with them.
I just wish I could code properly to start trying out something like that.
You'd need to do this when an app udaptes, too. (The update might introduce new tables.)
NC checks and compares tables, stores the new tables as corresponding to app
This is kinda fragil. New tables could have been added for other reasons concurrently, as AFAIK Nextcloud does not go into strict maintenance mode during app installs/updates (?). Also one might want to include app-specific rows or columns, not only tables, e.g. for removing obsolete background jobs (probably handled differently already, but you get the point). And an app install could theoretically trigger other components to pre-create tables which are used not only by the installed app, like Deck creating a calendar and the calendar app/API then pre-creates a probably other missing table, e.g. if it was freshly installed as well.
Most robust would be if all apps must declare where they want to write any data to (file system or database) and if Nextcloud would not allow them to write anywhere else and on install/update checks for conflicts in case. Then on uninstall those declarations could be gone through to remove really everything where the app ever requested to write data to. But it becomes a bit complicated when thinking about internal API usage, e.g. special calendar entries, which are not done directly but through an API (I guess?), and if it is really wanted that those are removed or not. And in other cases apps might intentionally share tables or directories.
So most practically is likely an optional list for what is removed when "purging" the app, very similar to how APT and other package managers do it via post-removal scripts (/var/lib/<name>/
content and such). It is then up to the app developers to implement/maintain those and up to the users to report when they find left-overs that are clearly only used by the particular app 馃槈.
yes, when is this coming, my installation is filling up with crap that needs to be removed
Most helpful comment
I would vote for this as well.
During my support in Nextcloud forums I install many apps for testing and my db has a lot of garbage in it. Some tables I delete manually, with the risk to damage my system.