Influxdb: Unable to backup a database using docker, returning no informative error message.

Created on 15 Feb 2018  路  10Comments  路  Source: influxdata/influxdb

Bug report

__System info:__ [Include InfluxDB version, operating system name, and other relevant details]
influxdb:1.4-alpine binding port 8086 to localhost.

__Steps to reproduce:__

  1. Run influxdb container.
  2. Tested manually the REST api to ensure it's working
  3. (from my mac or even from a docker container) influxd backup -host localhost:8086 -database test-database-example /tmp/backup

__Expected behavior:__ [What you expected to happen]
It should have generated a backup locally

__Actual behavior:__ [What actually happened]

2018/02/14 16:10:57 backing up db=test-database-example since 0001-01-01 00:00:00 +0000 UTC
2018/02/14 16:10:57 backup failed: invalid character 'H' looking for beginning of value
backup: invalid character 'H' looking for beginning of value
1.x need more info

All 10 comments

backup by api should connect to the port define in bind-address default is 8088锛宯ot http 8086

/# influxd config
Merging with configuration at: /etc/influxdb/influxdb.conf
reporting-disabled = true
bind-address = "127.0.0.1:8088"

It is better to change bind-address to ":8088" if you want to do remote backup. And also remember to make the port forward if you are using bridge network in docker.

8086 is binded for http, the global bind-address for backup is not working from outside.

8086 is default port for http api, 127.0.0.1:8088 is default address for remote backup utility. You can try cmd like : influxd backup -host localhost:8088 -database test-database-example /tmp/backup inside your influxdb container to verify the result.

inside it works, but when I run that from outside, "exposing 8088" using docker, it doesn't work.

It is better to change bind-address to ":8088"
Default configuration listen the port on localhost, you can just connect to that port inside the container.
Try to change the parameter by ENV, like add -e INFLUXDB_BIND_ADDRESS=":8088" at the docker run cmd.

I did that, which caused a problem of merging in the official docker image https://github.com/influxdata/influxdata-docker/issues/195

@pragmaticivan are you still experiencing this issue?

I had the same problem and changed the bind-address to ":8088" and I confirm it now works.

Although, doing this makes me opening this function to any remote hosts, and i find it very risky that the only thing that prevents someone from doing a backup is this IP level filtering.
Is there a way to enforce user/password protection over databases backup ?

As an intermediate solution, can we narrow the bind-address to a private network prefix, using some kind of wildcards ? for example: 192.168.*.*:8088 ?

I had the same problem, my problem was to backup influxdb (containerB) from another container (containerA).
To fix this I have added the influxd executable to the docker container that need to trigger the backup (containerA).

  1. Add this lines to the Dockerfile of containerA to install the influxd executable
#Install influxd
RUN echo 'hosts: files dns' >> /etc/nsswitch.conf
RUN apk add --no-cache tzdata bash

ENV INFLUXDB_VERSION 1.6.4
RUN set -ex && \
    apk add --no-cache --virtual .build-deps wget gnupg tar ca-certificates && \
    update-ca-certificates && \
    for key in \
        05CE15085FC09D18E99EFB22684A14CF2582E0C5 ; \
    do \
        gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
        gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
        gpg --keyserver keyserver.pgp.com --recv-keys "$key" ; \
    done && \
    wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb-${INFLUXDB_VERSION}-static_linux_amd64.tar.gz.asc && \
    wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb-${INFLUXDB_VERSION}-static_linux_amd64.tar.gz && \
    gpg --batch --verify influxdb-${INFLUXDB_VERSION}-static_linux_amd64.tar.gz.asc influxdb-${INFLUXDB_VERSION}-static_linux_amd64.tar.gz && \
    mkdir -p /usr/src && \
    tar -C /usr/src -xzf influxdb-${INFLUXDB_VERSION}-static_linux_amd64.tar.gz && \
    #copy just influx executable
    chmod +x /usr/src/influxdb-*/influxd && \
    cp -a /usr/src/influxdb-*/influxd /usr/bin/ && \
    rm -rf *.tar.gz* /usr/src /root/.gnupg && \
    apk del .build-deps
  1. Add the env variable INFLUXDB_BIND_ADDRESS to the docker-compose file and expose the port 8088.
influxdb:
    image: influxdb:latest
    container_name: influxdb
    environment:
      - INFLUXDB_BIND_ADDRESS=:8088
    expose:
      - "8088"
      - "8125/udp"
      - "8092/udp"
      - "8094"
    ports:
      - "8083:8083"
      - "8086:8086"
      - "8090:8090"
      - "8088:8088"
    volumes:
      # Data persistency
      # sudo mkdir -p /srv/docker/influxdb/data
      - /var/lib/influxdb:/var/lib/influxdb

Now If I enter the bash of the container docker exec -it containerA /bin/bash
And I trigger the command:
influxd backup -portable -host influxdb:8088 -database dbName /path/to/store/the/backup

I can successfully backup my db from another container.

Hope this will help someone.

please use the workaround provided.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scotloach picture scotloach  路  63Comments

cheribral picture cheribral  路  59Comments

beckettsean picture beckettsean  路  44Comments

toddboom picture toddboom  路  69Comments

mgf909 picture mgf909  路  72Comments