Migrate your existing persistence data to InfluxDB

I think this was already fixed by this PR in the master branch…

At least the %:z was removed.
I think you might have downloaded the outdated branch for v2.1.

I will update the first post, so new users will not use the outdated v2.1 branch.
Instead the master brach ist supposed to work with v2.5.5.

1 Like

Is it correct that only the last 30 days are being migrated?
I’m seeing the correct dates:

Command:

./rest2influxdb.sh fluksoElecB

Output:

### timestamps
item: fluksoElecB
10y:  2010-10-17T15:30:23
1y:   2019-09-19T15:30:23
1m:   2020-09-18T15:30:23
1w:   2020-10-10T15:31:23
1d:   2020-10-16T15:31:23
8h:   2020-10-17T07:31:23
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   202  100   202    0     0  22444      0 --:--:-- --:--:-- --:--:-- 25250
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2704  100  2704    0     0   330k      0 --:--:-- --:--:-- --:--:--  330k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26912    0 26912    0     0  2021k      0 --:--:-- --:--:-- --:--:-- 2021k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   229  100   229    0     0  32714      0 --:--:-- --:--:-- --:--:-- 38166
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12067    0 12067    0     0  1309k      0 --:--:-- --:--:-- --:--:-- 1309k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 23390    0 23390    0     0  2076k      0 --:--:-- --:--:-- --:--:-- 2076k

### found values: 1298

### Line from 1 to 1000
HTTP/1.1 100 Continue

HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: e8f5c243-107c-11eb-b196-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.4
X-Request-Id: e8f5c243-107c-11eb-b196-000000000000
Date: Sat, 17 Oct 2020 13:30:23 GMT

Sleep for 10 seconds to let InfluxDB process the data...

### Line from 1001 to 2000
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: eef0bba3-107c-11eb-b1a7-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.4
X-Request-Id: eef0bba3-107c-11eb-b1a7-000000000000
Date: Sat, 17 Oct 2020 13:30:33 GMT

Sleep for 10 seconds to let InfluxDB process the data...

### delete temporary files

RRD4 Graph:
rrd
Grafana/influxdb graph:

Any idea what I’m doing wrong?
Or does his only work on ‘empty’ databasefields? My current grafana installation is running for about 1-2 weeks…

try to check step by step where the data ist lost.

The script first creates XML-files fo speparated time periods.

Do these files look ok?

Then check if the ${itemname}.xml does contain all data you would expect.

The same for ${itemname}.txt

I hope this will help you find the issue.

1 Like

Does this script also works when the data is in mySQL ?

I guess so, because the script gets the data via the REST API and does not care what database is used in the background.

Thank you very much.
When I followed your analyses, I noticed that my date had some extra 00’s at the end of the date. With removing everything, clone it again, it works !!!

Next step, checking if I can export/import ‘all’ exisitng data now. Guess it’ll be a bit much, but that’s why we’ve computers, no? :wink:

Does the script work with OH3.2?

…or with OH3.3 and InfluxDB 2.4?

I’ve tried it and it seems the values were read from my MySQL database, but could not be written to InfluxDB 2.4.

 ./rest2influxdb.sh MQTT_Wetterstation_Temperature

### timestamps
item: MQTT_Wetterstation_Temperature
10y:  2012-09-23T14:23:41
1y:   2021-08-26T14:23:41
1m:   2022-08-25T14:23:41
1w:   2022-09-16T14:24:41
1d:   2022-09-22T14:24:41
8h:   2022-09-23T06:24:41
resturl:   http://openhab.fritz.box:8080/rest/persistence/items/MQTT_Wetterstation_Temperature?serviceId=jdbc&api_key=MQTT_Wetterstation_Temperature
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24.5M    0 24.5M    0     0  1221k      0 --:--:--  0:00:20 --:--:-- 5745k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.3M    0 10.3M    0     0  1242k      0 --:--:--  0:00:08 --:--:-- 2463k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  681k    0  681k    0     0  1414k      0 --:--:-- --:--:-- --:--:-- 1414k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  173k    0  173k    0     0  1443k      0 --:--:-- --:--:-- --:--:-- 1431k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24268    0 24268    0     0  1077k      0 --:--:-- --:--:-- --:--:-- 1077k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11343    0 11343    0     0   615k      0 --:--:-- --:--:-- --:--:--  615k

### found values: 988158
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
X-Influxdb-Build: OSS
X-Influxdb-Version: v2.4.0
X-Platform-Error-Code: unauthorized
Date: Fri, 23 Sep 2022 12:24:13 GMT
Content-Length: 48
Connection: close

Today I spent some time with the script and added a version which seems to work with openhab 3.3 and InfluxDB 2.4

I’ve forked the repository from @christoph_wempe and added a new script and cfg for use with InfluxDB 2.4. You can find it here:

(Sorry, if I’ve made something wrong with GitHub, it’s my first fork/repo :see_no_evil:)

For me it works fine, maybe my version helps someone else… :slight_smile: