Nextcloud version: 19.0.1
Operating system and version: CentOS 7
The issue you are facing:
I migrated my client from Windows 10 to Linux Mint 20. I have one folder connection between my Nextcloud and an encrypted external drive.
On Windows, if Nextcloud starts before the drive is mounted it detects that the drive is not available (even if it’s an encrypted drive that has not been decrypted yet) so it does not start the sync. On Linux, if Nextcloud starts before the drive is mounted it sees an empty directory and assumes everything has been deleted. It immediately syncs this to Nextcloud and causes all files to be deleted.
Is this the first time you’ve seen this error? (Y/N): Y
Steps to replicate it:
- Add a folder connection between Nextcloud and a mounted drive on Linux
- Start Nextcloud without the drive mounted
- Watch all of your files get destroyed
It really seems like there should be a check for this incredibly destructive behavior. Especially considering the same steps that work on Windows (start NC without the shared folder present) and Linux have completely different outcomes.
Part of the difference is probably that an unmounted filesystem in Linux literally is an empty folder with the same path. Are you syncing to the root of this mount? Syncing to a subfolder on it would result in a nonexistent folder rather than an empty one.
I agree there should be a sanity check before deleting every file…
You are correct that I’m mounting the root of my drive to the root of my Nextcloud. If I’m not mistaken,
Syncing to a sub-folder would require me to either set up individual folder connections and store no files in the root, or to push everything in my external drive down one directory. Right?
Unfortunately, neither of these are ideal :(.
I’ve thought about making a script for launching the Nextcloud client that creates the folder, mounts the drive, then starts Nextcloud. This would probably work most of the time; but it still seems too dangerous that if Nextcloud ever gets started without things being “just right” it will wipe out my files.
Yes, that would be my first suggestion. I’m trying to think of a way you could create a 2nd mount or symlink that would avoid the root sync situation, but nothing is coming to mind.
Also, you should file a bug on this behavior as it’s certainly not intended to wipe all your files.
Can you advise how to do this?
I’m not sure about that. What if you delete all your files from your sync directory while the client is not running?
I agree it’s possible. But out of 100 times, how many times do you think a user intends to delete all the contents of a folder sync pair, and how many times is it just because the folder is not mounted? It at least deserves a big scary warning, in my opinion.
Show me someone who has ever done that.