Search code examples
databasedockerinfluxdb

How to export an Influxdb database which is in a docker container?


I want to export my influxdb database as mentioned here, but my InfluxDB is in a docker container, and I'm still a beginner with it. How can I execute the following command into my container ? influxdb backup -database name /opt/data


Solution

  • You can do a docker exec & docker cp to backup your data in case you have not used host mounts -

    docker exec -it $CONTAINER_ID bash -c "influxdb backup -database name /opt/data"
    

    Once your data is generated in /opt/data, copy it to the current directory on Docker host -

    docker cp $CONTAINER_ID:/opt/data ./