# Backup and restore influxdb inside Docker

**URL:** https://community.influxdata.com/t/backup-and-restore-influxdb-inside-docker/1636
**Category:** Systems
**Created:** [July 16, 2017, 6:15am UTC](https://community.influxdata.com/t/backup-and-restore-influxdb-inside-docker/1636 "2017-07-16T06:15:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)
#### Post date: [July 16, 2017, 6:15am UTC](https://community.influxdata.com/t/backup-and-restore-influxdb-inside-docker/1636/1 "2017-07-16T06:15:31Z")

</div>

A few people have had trouble using backup and restore of influxdb inside Docker, so I wrote a small script demonstrating how to back up and restore a database, [in this gist](https://gist.github.com/mark-rushakoff/36b4491f97b8781198da36752ecd949b). If you’ve had trouble with backup and restore inside Docker, you should be able to use that script as a reference to make backup and restore work in your setup.

Some of the issues people are running into include:

- Trying to [run `influxd restore`](https://docs.influxdata.com/influxdb/v1.2/administration/backup_and_restore/) without stopping the `influxd` process
- General difficulties around influxdb inside Docker, particularly:
  - Stopping the `influxd` process which kills the container
  - Needing to `restore` into a volume from an ephemeral container

We’re looking into how to make this workflow easier. Right now, it seems like the most user-friendly answer will be to allow `influxd restore` to run correctly _without_ stopping the `influxd` process, but we are still considering whether any other approaches make sense.

---

<div class="post-metadata">

### Author: ![robertsLando](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/robertslando/32/955_2.png) [@robertsLando](https://community.influxdata.com/u/robertsLando)
#### Post date: [November 5, 2018, 3:48pm UTC](https://community.influxdata.com/t/backup-and-restore-influxdb-inside-docker/1636/2 "2018-11-05T15:48:14Z")

</div>

Hi, I have the same problem.

I need to backup the influxdb from another docker container running a NodeJS application that uses data stored in influxdb and has also backup/restore functionalities. To be able to use influx cli commands inside this container I have installed influx there too but it is not started, this way I can use the `influx backup` command.

I have just added this lines to my nodejs container Dockerfile:

```auto
ENV INFLUXDB_VERSION 1.5.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

```

I can connect to InfluxDB correctly:

```auto
bash-4.4# influx -host influxdb
Connected to http://influxdb:8086 version 1.6.4
InfluxDB shell version: 1.5.4

```

But when I try to run the backup:

`influxd backup -portable -host influxdb:8088 -retention autogen -database myDatabase ./`

I’m getting this response:

```auto
2018/11/05 15:15:48 backing up metastore to meta.00
2018/11/05 15:15:48 Download shard 0 failed dial tcp 172.19.0.3:8088: getsockopt: connection refused. Waiting 2s and retrying (0)...
2018/11/05 15:15:50 Download shard 0 failed dial tcp 172.19.0.3:8088: getsockopt: connection refused. Waiting 2s and retrying (1)...
2018/11/05 15:15:52 Download shard 0 failed dial tcp 172.19.0.3:8088: getsockopt: connection refused. Waiting 2s and retrying (2)...
2018/11/05 15:15:54 Download shard 0 failed dial tcp 172.19.0.3:8088: getsockopt: connection refused. Waiting 2s and retrying (3)...

```

I don’t undestand why but seems the port 8088 is not exposed, I have also tried to expose it in docker-compose but nothing works. Any ideas?
