I want ideas on reliability of external drive sync

The context: I have a local server running Nextcloud (a notebook) with an external drive connected via USB 3.0. The other day I needed to move things around and the connection to the external drive failed. I discovered this when I wanted to access something and the nextcloud folder to the external drive was empty. No problem. I gave a little wiggle to the USB and rebooted the system (I have automount configured, so this was a lazy way to restart it).

The actual problem: I was surprised to see that some folders that are synced to my workstation were deleted! So it needed to be downloaded all over again from the server.

The question: How could I prevent this from happening? Is it doable to script something to trigger an unmount or whatever so nextcloud does not think the folder was emptied?

Nextcloud 24.0.2
Ubuntu 20.04
Apache/2.4.41
PHP 8.0

This is a unresolvable problem unless you are willing to invest in a functioning system (like a drive that works, etc). Your reliability is shot since your usb drive is so sensitive to wiggle.

Nextcloud is not designed for this on again / off again setup.

You cannot because of your hardware. Are you willing to invest some actual money into your hardware in order to have a functional Nextcloud setup?

Nextcloud is not a good fit for your use case with the faulty hardware. I recommend using a VPS or a paid provider that will never have this issue of random disconnection.

Corruption and sync issues are guaranteed on any system due to faulty hardware connectivity. You cannot trust faulty hardware, because it cannot properly sync or function with any sort of reliable uptime.

Hi, apart from moving the files to an internal disk, you might consider creating a script that checks if the drive is connected every few seconds and automatically enable the maintenance mode if it is not. This will work around the issue.

1 Like

You can create a udev rule that senses when a USB drive is connected or not and then trigger some operation regarding the sync operation.

https://unix.stackexchange.com/questions/229987/udev-rule-to-match-any-usb-storage-device

and arch udev documentation… which is by far one of the best out there:

https://wiki.archlinux.org/title/udev

1 Like