Moving files, on the client or server side, without forcing everything to re-sync

I’ve had this happen a number of times, so I’d like to avoid it moving forward. I’ll give you an example:

I have a second drive in my computer, internal or external, with a bunch of music on it. The drive starts to get old, and I decide it’s time to replace it. So I copy all my MP3s from the old drive to the new one, unmount the old drive, and mount the new one where the old one was. So far, so good: Nextcloud detects the directory just as it did before.

Here’s the problem: in every case, Nextcloud will immediately start overwriting all my local files with the ones on the server. This isn’t the end of the world, but the reason I manually copied my files was so that I wouldn’t have to download them all over again.

At first I thought this had to do with mismatched partition types, but it happens even when the old and new folders are on ext4 partitions (my server is also ext4—even the external storage).

I will also point out that in the case I described, the server-side files are accessible through Nextcloud as external storage (it’s an external drive). I don’t know if that matters.

Right now, I’m getting ready to replace the external storage on the server side (I run self-hosted Nextcloud on my LAN). I’m worried that when I disconnect the old drive, and mount the new one in the same place, I’m going to have the same problem where a ton of stuff is going to get transferred.

Could this be related to missing, hidden files? If I make sure all the dotfiles transfer to the new media, will this solve the problem? Or is it something else?

1 Like

I just went to start this exact thread again, not realizing I had already asked this. This week, I copied a lot of files to an SD card, put them in my phone, and set up a folder sync connection in Nextcloud. I copied the files from an already-synced folder on my computer.

Well, Nextcloud still tried to sync about a third of the files — 50GB. The constant writing actually corrupted the SD card, which then synced hundreds of newly-corrupted files back to NC, destroying my data in all locations.

I bought a new SD card and I was able to piece together the files from an old backup. When I get my SD card, I want to take my restored files, copy them to the SD, put it into my phone, and re-establish the folder sync connection, without having to go through this again. How do I mirror the files from Nextcloud, manually, before I sync, to Nextcloud doesn’t try to sync what’s already there?

If you do such changes, make sure to copy the files and keep the time stamps of the files:

If you copy files with the cp command, you can use the -p flag to preserver the attributes (file owner, timestamps, permissions).

You can as well use the rsync command (can also be used over the network and tunneled through ssh):
rsync -Aavx /path/of/old/location /path/of/new/location
(Backup — Nextcloud latest Administration Manual latest documentation)

When you mount/unmount drives and when you move files around, I’d stop the Nextcloud client (if changed on the client), or stop (or at least, or both put in maintenance mode). Nextcloud shouldn’t see any changes.