bestlibre / hassio-addons

173 stars 110 forks source link

InfluxDB Remote Backup #85

Closed MisterCommand closed 5 years ago

MisterCommand commented 5 years ago

Hi, How to make a remote backup of InfluxDB,? There should be an additional port for remote backup.

zbb67 commented 5 years ago

+1 request for an answer to this if any knows? I'm migrating from Pi to Docker and would like to copy my old sensor info from pi's Influxdb to the new Docker's Influxdb.

I put this in the Pi Hassio (from BestLibre) add-on config and restarted.

{ "env_var": [ { "name": "INFLUXDB_BIND_ADDRESS", "value": ":8088" } ] }

I'm not sure that's worked though as nmap shows that the pi still seems only to have 8086 open, not 8088.

I can ping the Pi from the new Docker container, so network path is OK.

From inside my Influxdb docker container on a new host, I can see the database through port 8086;

curl -G http://192.168.1.10:8086/query --data-urlencode "q=SHOW DATABASES" {"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["home_assistant"]]}]}]}

But when I try to create a remote backup from the docker container it fails;

root@78febe215d89:/# influxd backup -database home_assistant -host 192.168.1.10:8088 /var/lib/influxdb/pi-influxdb-backup 2018/09/06 16:32:44 backing up metastore to /var/lib/influxdb/pi-influxdb-backup/meta.00 2018/09/06 16:32:44 Download shard 0 failed dial tcp 192.168.1.10:8088: connect: connection refused. Waiting 2s and retrying (0)... 2018/09/06 16:32:46 Download shard 0 failed dial tcp 192.168.1.10:8088: connect: connection refused. Waiting 2s and retrying (1)... ...etc.

Anything I'm missing? I suspect I've not opened port 8088 properly, syntax on the config perhaps? Has anyone got remote backups working against Hassio Influxdb addon?

Thanks

ricveal commented 5 years ago

The Dockerfile only exposes 8086 port and that is the reason why even adding INFLUXDB_BIND_ADDRESS property, the port is not accesible from another host.

I will open a new PR to expose the port 8088 too 😄

zbb67 commented 5 years ago

I will open a new PR to expose the port 8088 too

That's great, thanks very much :-)

zbb67 commented 5 years ago

Thanks again for this change. I'd kept my Pi running in the hope that this would work out and I'd recover my historical data, that's just been accomplished.

If it helps anyone else migrating from pi to docker, this worked well for me;

Log into new docker influxdb container console, and run;

mkdir /var/lib/influxdb/pi-influxdb-backup

influxd backup -portable -database home_assistant -host <IP of pi>:8088 /var/lib/influxdb/pi-influxdb-backup

influxd restore -portable -db home_assistant -newdb pihome_assistant /var/lib/influxdb/pi-influxdb-backup

influx
> USE pihome_assistant
> SELECT * INTO home_assistant..:MEASUREMENT FROM /.*/ GROUP BY *
> DROP database pihome_assistant
> exit

Thanks again :-)