Recover single measurement data

I need to recover the data of a single measurement . I have the data on my primary server . I also have the backup for the full database.

Is there any way to export the data for the single measurement in “line protocol” format so it can be piped to curl -X post to second server

Any help is appreciated.

I see there is something like
influx_inspect dump -path /var/lib/influxdb/data -database mydatabase -output /tmp/mydatabase.dump

for the “database” , can we mention “database.measurement” to just get a single measurement ?

Well - I made some progress finally…

Exported out the fulll db first !
influx_inspect export -compress=“true” -database indicators -datadir /var/opt/influxdb/data -retention autogen -waldir /var/opt/influxdb/wal -out /var/opt/influxdb/backups/indicators.dmp

now it its super long for a 28gb database. ( du -sh * output )

it seems like it created a gzipped exact copy file of about 26 gb ! interesting!

now I did extract out the data for the relevant measurement

– this was equally slow but acceptable!

time zcat indicators.dmp |grep “^BB3_MA” > bb3_ma.txt

I will update if this file will load as is ( looks promising ! )

update:

I changed the measurement to _test to test what was going in… using sed in the extracted file

So I was able to load the data in batches of 4k rows ( 5 k is max allowed )

Interestingly it created a _temp measurement along with it and I believe it skipped a part of the data that was past retention time of 1 w.

I wish some one from Engg can help verify the data in the temp tables data !

> show measurements on indicators with measurement =~ /BB3_MA.*/
name: measurements
name
----
BB3_MA_test
BB3_MA_test_temp
>
> select count(*)  from BB3_MA_test_temp
name: BB3_MA_test_temp
time count_Domain count_Group count_Identity count_MA_12H count_MA_2D count_MA_5D  count_MA_6H count_SD_12H count_SD_2D count_SD_5D count_SD_6H
---- ------------ ----------- -------------- ------------ ----------- ----------- ----------- ------------ -----------  --------- -----------
0    81752        81752       81752          81752        81752       81752       81752       81042        81395        81565       80535
> select count(*)  from BB3_MA_test
name: BB3_MA_test
time count_MA_12H count_MA_2D count_MA_5D count_MA_6H count_SD_12H count_SD_2D  count_SD_5D count_SD_6H
---- ------------ ----------- ----------- ----------- ------------ ----------- ----------- -----------
0    117165       117165      117170      117165      116133       116659      116874      115523

what does the temp measurement has ?

The best way to recover online ( without any outage of the server ) for a single measurement that works for me now is

  1. get the table output as csv file using select *
  2. Use perl script to transform it into Line protocol file ( change any measurement name etc )
    ( I did not try out inserting directly from perl line protocol influxdb library yet )
  3. insert using “influx import” to the specific database as appropriate. ( fastest)

Be careful as I understand that if you are importing back to the same database and same measurement , it may update the rows with same time stamps.