I have plenty of machine which running on old ways of Virtual Machine. Recently i’m interested to looking for a simpler, more automated approach to installation rather than install one by one each machine.
Currently i would like to migrate 1 set of Grafana, Influxdb, Prometheus to Docker. I will post more detail about docker later, but for this article i would like to write more specific to migrate from InfluxDB database to Docker.
InfluxDB Databases
First, let’s take a look at the InfluxDB databases. In this example, we are using version 1.8.10, and we have two databases that we want to back up: telegraf and librenms.
To see a list of the available databases, run the following command in the InfluxDB shell:
# influx -host 127.0.0.1 -port 8086
Connected to http://127.0.0.1:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES;
name: databases
name
----
telegraf
_internal
librenms
> exit
#
Backup Databases
Once we’ve identified the databases that want to back up, run the following commands:
# influxd backup -portable -database telegraf ./influxdb-backup/telegraf
# influxd backup -portable -database librenms ./influxdb-backup/librenms
These commands will create portable backups of the databases in the specified directories. After required database backed up, then we can copy the directory using scp to destined docker host.
scp -r /root/influxdb-backup/ root@destination_docker_host:/home/
Restoring Databases

I have built several service related grafana monitoring using docker compose to provision these container.
influxdb:
image: influxdb:1.8.10
container_name: influxdb
ports:
- "8086:8086"
volumes:
- /opt/appdata/influxdb:/var/lib/influxdb
restart: unless-stopped
After container up then we stop the services using docker stop influxdb. Then we create intermediate container that maps the data volume and our backup directory and then enter the container’s shell:
# docker run --rm --detach -v /opt/appdata/influxdb:/var/lib/influxdb -v /home/influxdb-backup/:/backups -p 8086 influxdb:1.8.10
b87c1e0dcfbdc3250e65c9664cae00b39df9493334bb098ba58be54aeec6b281
# docker exec -it blissful_cori /bin/bash
root@b87c1e0dcfbd:/# influxd version
InfluxDB v1.8.10 (git: 1.8 688e697c51fd)
# influxd restore -portable -database telegraf /backups/telegraf
# influxd restore -portable -database librenms /backups/librenms
# exit
Then stop intermediate container and remove then start influxdb container.
docker stop blissful_cori
Now you can log in to the InfluxDB console and verify that the databases have been restored:
root@bb0711aa705e:/# influx -host 127.0.0.1 -port 8086
Connected to http://127.0.0.1:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES;
name: databases
name
----
_internal
telegraf
librenms
>
Note that you should also check the InfluxDB version on the existing and new systems to ensure compatibility.
References :
https://dev.to/thibmaek/-migrating-influxdb-databases-to-docker-compose-2kee