InfluxDB data restore in docker container

Hi,

Im in the process of migrating from standalone hass to hass.io. but i cannot find out where to run the influxd restore command.

I have been able to backup my influxdb as per instructions here. https://docs.influxdata.com/influxdb/v1.2/administration/backup_and_restore/

Now im a very new to the docker landscape, can someone tell me where/how i can run the restore command from? i have SSH’ed using the addon and direct to port 22222 and in neither places could i get could i get anything from running which influxd

Any help appreciated
Cheers
Willie

The addons for hassio runs in their own containers. You have to docker exec into the right container.

Thanks heaps @LarsNorgaard, that just the pointer I needed,

example that worked for me docker exec addon_53caca22_influxdb influx -execute 'show databases'

Might not be through the woods yet, i can run commands in the container but when i try and do the restore and refer to files, I have some errors.

I suspect is my lack of knowledge around referencing files from the docker container.

root@hassio:~# ls /tmp/influxbackup/
home_assistant.autogen.00130.00  home_assistant.autogen.00173.00  home_assistant.autogen.00290.00  home_assistant.autogen.00407.00  home_assistant.autogen.00524.00
home_assistant.autogen.00131.00  home_assistant.autogen.00182.00  home_assistant.autogen.00299.00  home_assistant.autogen.00416.00  home_assistant.autogen.00380.00  home_assistant.autogen.00497.00  meta.00
home_assistant.autogen.00155.00  home_assistant.autogen.00272.00  home_assistant.autogen.00389.00  home_assistant.autogen.00506.00
home_assistant.autogen.00164.00  home_assistant.autogen.00281.00  home_assistant.autogen.00398.00  home_assistant.autogen.00515.00
root@hassio:~# docker exec addon_53caca22_influxdb influxd restore -database home_assistant -datadir /resin-data/addons/data/53caca22_influxdb/influxdb/data /tmp/influxbackup/
restore: no backup files for /tmp/influxbackup/home_assistant.* in /tmp/influxbackup/

Any solution to this?

I am in the process of migrating from Rpi to Hassio in Docker, and can not get the snapshot to restore the influxDB databases.

What you are attempting here looks just like what I need to do aswell.

I just ran into a similar issue so I thought I’d post my solution in case anyone else stumbles across this like I did.

I installed the InfluxDB Home Assistant add-in to get InfluxDB on my new computer. I then created a database and tested writing data to it from Node-RED. Once I had this working I started the restore process. Note: I captured my backup before I started inserting data into my new database so there was no duplicate data.

I backed up the database with this command (make sure to stop the data from being written to the database being backed up)

influxd backup -portable /home/olduser/influxdbbackup

I then copied the influxdbbackup directory to the new computer and placed it in my Documents folder.

I needed to find the storage the Docker container has access to. I found the “binds” section after running the command below which tells me I can put the data into the /data or /share folders.

docker container inspect 6728455ebcd8

Here is part of the result:
“HostConfig”: {
“Binds”: [
“/home/newuser/Docker/hassio/ssl:/ssl:ro”,
“/home/newuser/Docker/hassio/share:/share:rw”
],

Then I ran this command to copy the backup files to a location that the InfluxDB container can access (/share):

sudo cp /home/newuser/Documents/influxdbbackup /home/newuser/Docker/hassio/share -r

To get in to the docker container I logged in to the new laptop and used Docker Exec

docker exec -it addon_a0d7b954_influxdb bash

I then navigated to the share folder with this command:

cd share/influxdbbackup

Because I already had the database created I used this command to restore the data to a temporary database.

influxd restore -portable -db OriginalDatabaseName -newdb TempDBName /share/influxdbbackup

I then ran this to merge the data into my existing, new database:

influx -database TempDBName -username YourUserName -password YourPassword 
SELECT * INTO ExistingDatabase..:MEASUREMENT FROM /.*/ GROUP BY *
3 Likes

Thanks for the info. This help a lot. Im still searching how to backup influxdb database every night. Without the risk the database is corrupt…