NextCloud - Force Remove External Mount Point
I am creating this post for reference. It was difficult to find a one-stop answer on how to do this and why it occurs. Hopefully this response will serve that purpose.
If you can’t remove an external mount point or get the following sync error
Client does not sync/The server file discovery reply is missing data
You may go into the web application and see that you have an unknown storage provider on one of your external mount points.
In my case, it was Google. Some posts say that updating the extension for Google Drive will fix it, but there was no explanation of how to do that. It doesn’t look likes it’s a plug-in.
If you just want to remove the link, you can try to delete it from the Web UI by clicking the checkbox next to the folder and selecting the remove item from the dropdown menu.
If the web UI removal method does not work, the occ
command must be used.
The following will remove the link from NextCloud to the external provider you choose.
Remove an external storage provider from the command line
Hop onto the terminal or command prompt in order to issue the external files occ
commands.
First, I will provide a walk-through of the commands, then I will show the commands in action. I will also give two variations of the commands for terminal and docker usage.
Open a docker interactive terminal (if you’re using docker with the official image)
sudo docker exec -it docker-nextcloud /bin/bash
List the currently active mount points for all users
Standard Usage
occ files_external:list -a
Docker
su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data
Delete a selected mount using the mount’s ID
Standard Usage
occ files_external:delete <Mount ID>
Docker
su -c "php /var/www/html/occ files_external:delete <Mount ID>" -s /bin/sh www-data
Command results for reference
These commands were issued from inside a docker container, so they command syntax will look different if you’re using the terminal (as discussed previously) or if you are using a different image base in your docker container.
List ALL of the mount points as the root user
root@mydockercontainer# su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| Mount ID | Mount Point | Storage | Authentication Type | Configuration | Options | Applicable Users | Applicable Groups | Type |
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| 2 | /BoxDotCom | WebDAV | Username and password | host: "dav.box.com\/dav", root: "NextCloud", secure: true, user: "emai1@local.com", password: "***" | | user1 | | Personal |
| 3 | /GDrive | Unknown storage backend googledrive | OAuth2 | configured: "true", client_id: "xxxxxx...al.com", client_secret: "***", token: "***" | | user2 | | Personal |
+----------+-------------+-------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
Pick out your ID from the results
I choose number three which is associated with the provider type and user that is having the issue.
Delete the mount and confirm when prompted
root@mydockercontainer# su -c "php /var/www/html/occ files_external:delete 3" -s /bin/sh www-data
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
| Mount ID | Mount Point | Storage | Authentication Type | Configuration | Options | Applicable Users | Applicable Groups |
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
| 3 | /GDrive | Unknown storage backend googledrive | OAuth2 | configured: "true", client_id: "xxxxxx...al.com", client_secret: "***", token: "***" | | user2 | |
+----------+-------------+-------------------------------------+---------------------+--------------------------------------------------------------------------------------+---------+------------------+-------------------+
Delete this mount? [y/N] y
List ALL of the mount points again to ensure it’s gone
root@mydockercontainer# su -c "php /var/www/html/occ files_external:list -a" -s /bin/sh www-data
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| Mount ID | Mount Point | Storage | Authentication Type | Configuration | Options | Applicable Users | Applicable Groups | Type |
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
| 2 | /BoxDotCom | WebDAV | Username and password | host: "dav.box.com\/dav", root: "NextCloud", secure: true, user: "email@local.com", password: "***" | | user1 | | Personal |
+----------+-------------+---------+-----------------------+----------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+----------+
Go back to the browser and verify that the issue is fixed
I was also able to go into the client sync at this point and force a sync which cleared away the red x and errors I was experiencing.
Hope this helps anyone looking for an answer!
REFERENCE:
[https://docs.nextcloud.com/server/14/admin_manual/configuration_server/occ_command.html?highlight=occ#files-external-label