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

0 Members and 1 Guest are viewing this topic.

Offline stromb0li

  • Member
  • *
  • Posts: 25
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: 1549
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).

Froggit WH4000SE (=EW 2320E) 1.6.4/GW1100 2.1.4/Froggit DP1500 1.6.8 (+EW GW1000 (4) 1.6.8/7.2 test/backup)/HP1000SE Pro (HP2551) 1.6.4/1.7.8, WH2650 WiFi (2) 1.7.2,GW2000 2.1.4;
Ecowitt WS90-,WS80,WH40,WH65,WH31(5),WH31-EP(1),WN30/DP30 (1),WH32(1),WH32-EP(1),WH32B [T/H/P] (1), WH57 [Lightning] (1), WH41 [PM2.5] (2), WH51 [SoilMoisture] (5), WH45, WH55 (2)
MeteobridgePro(2)[test,prod 5.4 May 07 2022, 14745 - Blake-Larsen Sun Recorder - RPi4/weewx 4.8.0/CumulusMX 3184/MB RPi4(2671)
Barani Meteoshield Pro, MetSpec Rad02
Ecowitt 5763,34418;WU ISAARB3(WH4000SE), ISAARB22(HP2553), http://meshka.eu

Offline stromb0li

  • Member
  • *
  • Posts: 25
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!

 

anything