Author Topic: How to migrate WeeWX database?  (Read 2259 times)

0 Members and 1 Guest are viewing this topic.

Offline stromb0li

  • Member
  • *
  • Posts: 26
How to migrate WeeWX database?
« on: July 19, 2021, 12:17:26 PM »
Hey WXForum,

Is there any documentation on redeploying WeeWX from scratch, but retaining historical data?

I've been running WeeWX for about 3-4 years now and have absolutely loved it, however, when I originally setup WeeWX, I put it on a machine that is nearly 15 years old now and I think it's finally time to change it out of rotation.  I'd like to completely redeploy WeeWX with factory defaults, but would like to keep my historical data that I've collected the past few years if possible as well.

Thank you!

Offline Gyvate

  • Forecaster
  • *****
  • Posts: 3297
Re: How to migrate WeeWX database?
« Reply #1 on: July 24, 2021, 06:49:33 AM »
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).

WS2350 1.6.7, GW1000(3) 1.7.7,WH2650 WiFi (2) 1.7.7 (test/backup), GW1100 2.3.1, GW2000(3) 3.1.1, HP2551 1.9.5,5.1.5;HP3500 1.7.2,WS3800 1.2.8, WN1910 1.2.3,WN1980 1.2.3;
Ecowitt WS90(2)1.3.5/1.4.0, WS80(2)1.2.5, WS68, WS69, WH40, WH31, WH31-EP, WN30, WN34L, WN35, WH32, WH32-EP, WH32B, WH57 [Lightning], WH41 [PM2.5], WH51, WH45, WH55
MeteobridgePro(2)[test,prod] 5.8 Mar 01 2024, 15185 - Blake-Larsen Sun Recorder - RPi4/weewx 4.8.0/4.10.2/CumulusMX 3283/Meteobridge RPi4B-2GB(3169)
Barani Meteoshield Pro, MetSpec Rad02 - Ecowitt 5763,34418;WU ISAARB3(WH4000SE),ISAARB22(HP2553), http://meshka.eu

Offline stromb0li

  • Member
  • *
  • Posts: 26
Re: How to migrate WeeWX database?
« Reply #2 on: July 24, 2021, 01:53:52 PM »
Ended up copying /var/lib/weewx/weewx.sdb from the older machine and writting over the top of the one on the new machine.  Worked perfect! :P  Thanks!

Offline JosephDemps

  • Member
  • *
  • Posts: 3
Re: How to migrate WeeWX database?
« Reply #3 on: September 04, 2023, 06:49:06 AM »
Even though the thread may have aged a bit, the challenges you were addressing and the careful approach you took continue to resonate.
In the realm of data management, have you ever delved into the depths of database design and development solutions? They offer a wealth of knowledge on how to efficiently structure and manage historical data.
Your dedication to enhancing your WeeWX setup while preserving your data history exemplifies your proactive and thoughtful approach to technology evolution. Embracing both the new and the existing showcases your strategic mindset.
« Last Edit: September 05, 2023, 08:27:44 AM by JosephDemps »