In the simplest case, you just do a clean new install (re-using your old weewx.conf and all modifications you may have made to skin.conf and *.inc and index.html.tmpl from the /etc/weewx/skins/YourSkin directory - YourSkin could be Seasons or whichever skin you use). Make sure that the database schema used in the new installation is the same as in the old one.
################################################ weewx.conf ##############################
# This section binds a data store to a database.
[DataBindings]
[[wx_binding]]
# The database must match one of the sections in [Databases].
# This is likely to be the only option you would want to change.
database = archive_sqlite
# The name of the table within the database
table_name = archive
# The manager handles aggregation of data for historical summaries
manager = weewx.manager.DaySummaryManager
# The schema defines the structure of the database.
# It is *only* used when the database is created.
schema = schemas.wview_extended.schema##############################################################################
Once the new weewx (e.g. 4.5.1) is running properly for the first time (syslog shows a proper archiving entry), stop weewx and copy your old weewx.sdb into the directory where your weewx database resides (e.g. /var/lib/weewx - the path will depend on your installation method - see weewx WIKI/documentation) overwriting your "test"/first install database . Then restart weewx and that's it.
that's for a sqlite database, but for a mySQL database the procedure should be analogous. With a mySQL database you might need to export your data from the old and import them again into your new one. See weewx tools in the weewx documentation (
www.weewx.com/docs.html)
You can avoid data loss by installing weewx on your new server (e.g. RPi4) and copy the database over from your old (still running) installation in the archiving window (usually 300 seconds = 5 minutes; but may be different in your setup).