Okay, I found some useful material for migrating the SQLite database to Postgre. There is a actually tool for this in the matrix-synapse package called synapse_port_db
. A detailed instruction can be found in their Github repository.
As to the migration from Raspberry 3B+ to Raspberry 4B 8GB I will try a manual migration of the LDAP directory in combination with my regular borg backups. I already installed Freedombox by using a fresh Raspberry Pi Debian image which already has corrected the RAM recognition bug. It seems to work as expected. I will post further updates if I succeed.