|
|
If you've been using weewx with a different template before, you most likely have some archive data you don't want to lose. While this can become a painful journey, there are several ways to migrate your old data:
|
|
|
|
|
|
# Automatic migration script (beta)
|
|
|
**WARNING: This is still pretty new and untested!
|
|
|
Do a backup of your weewx database (e.g: `/var/lib/weewx/`) before trying!**
|
|
|
|
|
|
I've written this script for one-time-use and it has done its job for me, so I won't update or enhance it any time soon. If you can use it: Fine. If you can't, continue at "Manual migration"
|
|
|
|
|
|
The script takes data stored in imperial units from an sqlite database, converts them to metric units, interpolates and stores them to json files inside the current directory as needed by the Rabenwetter archive.
|
|
|
This can be a LOT! So always run the script somewhere reasonable. E.g: `/var/www/weewx/archive/`:
|
|
|
|
|
|
```
|
|
|
/path/to/sqlite2json.php <inputfile>
|
|
|
```
|
|
|
#### For example:
|
|
|
```
|
|
|
/root/template_rabenwetter/src/tools/sqlite2json.php /var/lib/weewx/weewx.sdb
|
|
|
```
|
|
|
|
|
|
# Manual migration
|
|
|
|
|
|
It's a bit complicated and I don't recall all the steps, but here's some rough
|
|
|
information to point you to the right direction:
|
|
|
|
|
|
* **Stop weewx if running:**
|
|
|
> ```
|
|
|
> /etc/init.d/weewx stop
|
|
|
> ```
|
|
|
|
|
|
* **Uncomment [Lines 305-306](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf#L305) and [Lines 314-315](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf#L314) of your [skin.conf](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf):**
|
|
|
```
|
|
|
[[[adayjson]]]
|
|
|
template = archive/aday-YYYY-MM.json.tmpl
|
|
|
```
|
|
|
and
|
|
|
```
|
|
|
[[[ayearjson]]]
|
|
|
template = archive/aweek-YYYY.json.tmpl
|
|
|
```
|
|
|
|
|
|
* **Start weewx and watch its logs:**
|
|
|
> ```
|
|
|
> /etc/init.d/weewx start
|
|
|
> tail -f /var/log/syslog
|
|
|
> ```
|
|
|
|
|
|
You should soon see weewx exporting its complete database to .json files.
|
|
|
This takes some time, is quiet cpu intensive and will restart as soon as finished.
|
|
|
So continue watching the logs and
|
|
|
|
|
|
* **Stop weewx again as soon as the export is finished**
|
|
|
> ```
|
|
|
> /etc/init.d/weewx stop
|
|
|
> ```
|
|
|
|
|
|
* **Comment [Lines 305-306](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf#L305) and [Lines 314-315](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf#L314) of your [skin.conf](https://gitlab.ambhost.net/stimpy/template_rabenwetter/blob/master/dist/skin.conf) again:**
|
|
|
```
|
|
|
# [[[adayjson]]]
|
|
|
# template = archive/aday-YYYY-MM.json.tmpl
|
|
|
```
|
|
|
and
|
|
|
```
|
|
|
# [[[ayearjson]]]
|
|
|
# template = archive/aweek-YYYY.json.tmpl
|
|
|
```
|
|
|
|
|
|
* **Start weewx again...**
|
|
|
|
|
|
Now you have all the data from your database exported to json files, but concentrated to files, weewx can't handle.
|
|
|
This is because of the way, we had to export the data using the archive function of weewx.
|
|
|
You'll need to extract and split the files to those needed by the template:
|
|
|
`day-YYYY-MM-DD.json`, `week-YYYY-WW.json`, `month-YYYY-MM.json` and `year-YYYY.json`
|
|
|
|
|
|
I did this with some simple bash scripting logic using sed and grep, but I don't have the scripts
|
|
|
anymore, so I can't share them. Sorry...
|
|
|
|
|
|
All future data will get exported and saved automatically in the correct format. |
|
|
\ No newline at end of file |