Threema offers to back up the keys, contacts, groups and settings. Per default this backup is stored (encrypted !) on Threema’s servers.
But there’s a way to store the backup on an own nextcloud instance ! I found instructions on how to set it up.
The biggest catch is to click on “expert settings” when setting up the backup - this is where the nexcloud target can be configured. Without it, the backup goes to Threema’s servers.