Syncing new install overwrites local files. Expected behaviour?

Nextcloud version: TrueCharts 28.02
Operating system and version (eg, Ubuntu 20.04): truenas Scale + macOS Ventura

After reinstalling NC on the server side (docker container) and re-linking the client, NC populated the local NC folder with the default NC files, deleting all existing folders without warning. Moreover, these local files and folders were not in the trash either.

Is this expected behaviour?

Not at all!

At no time, under no circumstances, things like yours should happen! There must be a bug somewhere and it’d nice if you could open issue on GH with description of what happened.

This sound similar to my incident

It submitted this to GitHub. It turns out this is expected behaviour. Be aware…

It sounds like you’re trying to sync a preexisting client with a replacement server.

This is expected behavior:

Restoring backup — Nextcloud latest Administration Manual latest documentation

In a true server replacement situation you’d presumably have matching data already on the server-side (i.e. restored from a backup)… Or you’d follow the approach described in the above link to override treating the server as authoritative.

In your scenario you’re doing neither. Either configure a second account in the client and treat the new server as a new server (which it sounds like it is)… Or follow the above documented approach.