Data loss after external harddrive unmounted

Hi,

I’ll fill in the following info later …

Nextcloud version (eg, 20.0.5): replace me
Operating system and version (eg, Ubuntu 20.04): replace me
Apache or nginx version (eg, Apache 2.4.25): replace me
PHP version (eg, 7.4): replace me

My Ubuntu machine harddrive ran out of space due to Nextcloud copying deleted files into its main folder. I have files stored on an external HD due to not having enough space on my main device. So first …

How do I make Nextcloud store deleted files on external storage ?

So as part of making space on the device again I unmounted the external hardrive. I had not stopped apache2. This led to deletion of all the files on external storage once it was reconnected. I did not delete the files on any synced devices. This surprised me as, even though I realised Nextcloud had not been stopped (apache2), nothing had been explicitly deleted only unmounted. Luckily I had a backup of all the data elsewhere.

How can I prevent Nextcloud assuming files have been deleted when an external storage is unmounted or removed ?

Any help appreciated.

If you unmount, there are not files at the mount point any more!

E.g. if you have your drive mounted on /mnt/drive, once it is mounted, I would put the files in a subfolder /mnt/drive/data and use that as external storage. Once the disk is unmounted, the external folder /mnt/drive/data does not exist any more. Perhaps then it recognized that the folder is not available and it just doesn’t work on Nextcloud (until you reconnect it). And it doesn’t think that the files are deleted.

With LVM you can also create virtual drives that span over more than one physical device. So in your OS it looks like one big disk. However, I wouldn’t do that with external devices that can be disconnected.