How-to: Completely Remove Nextcloud from UCS

HowTo: Completely Remove Nextcloud from UCS Including All Residual Data

Summary

This article describes how to completely remove Nextcloud from a UCS environment.
It explains the correct procedure for uninstalling the app via the Univention App Center and details the follow-up steps required to clean up configuration files, databases, and application data.


Steps:

1. Uninstall Nextcloud

To uninstall Nextcloud from UCS, run:

univention-app remove nextcloud

This command removes the Nextcloud app but leaves application and user data intact.


2. Remove UCR Variables

Nextcloud-related UCR variables can be reset with the following command:

ucr unset "ucr search --key "^nextcloud" | cut -d ":" -f 1 | grep nextcloud | tr '\n' ' '"

This unsets all configuration variables containing the nextcloud key.


3. Remove the Database

Nextcloud uses a PostgreSQL database. To remove the database, the database user, and the password file, run:

su -c "psql -c \"drop database nextcloud\"" - postgres && \
su -c "dropuser \"nextcloud\"" - postgres && \
rm /etc/postgresql-nextcloud.secret
  • The first command deletes the nextcloud database.
  • The second command removes the nextcloud database user.
  • The third command deletes the secret file containing the database password.

4. Remove the Nextcloud Application Folder

The application folder contains UCS-specific application data as well as the Nextcloud data directory. To remove it, run:

rm -Rf "/var/lib/univention-appcenter/apps/nextcloud"


Notes

  • Ensure that no important user data remains in Nextcloud before executing these steps, as they will permanently delete all associated data.
  • Create a backup of relevant data if required.