Migrating my UPS data in InfluxDB to a new InfluxDB container

So a couple of months ago I wrote this post about how to setup InfluxDB and Grafana to show UPS stats.
And in that post I used the telegraf database that was already present. I used that database out of convenience rather anything else. A week ago I was inspecting  my files with diskover and to my surprise I saw that the InfluxDB appdata folder was by far the largest one out of all my containers!

[eckosc_quote quote=”I don’t care what the temperature of CPU Core 17 was May 4th last year..” source=”” url=”” pull=”false”]

Now I immediately thought it was all the UPS data I was feeding the database but when giving it some more thought I realised that it couldn’t be the UPS data. That script only polls the apcupsd every minute, so it couldn’t possibly be the offender.

Then I remembered all the other data that the telegraf container pushes..
For me that data is useless and I won’t use it for anything than “in the moment” inspecting.
I don’t care what the temperature of CPU Core 17 was May 4th last year..
I do care about my UPS stats though, and at the rate the telegraf database is growing it will be a pain backing it all up.
So that’s why I’ve decided to migrate the data to a new database in a completely different InfluxDB container!

On the screenshot to the right you can see the “File Tree” view in diskover.  Pretty obvious which folder is the largest.


Copying the appdata

Stop the InfluxDB container
Copy the appdata to a new folder in your Docker appdata location e.g /influxdbups

[email protected]:/mnt/cache/Docker# cp -R -v influxdb/ /mnt/cache/Docker/influxdbups

Add the new InfluxdbUPS container and set the appdata location to the folder you created (/mnt/cache/Docker/influxdbups)

Remember to use different ports!

Exec into the container with docker exec -it InfluxdbUPS bash
Run the command influx
Run the command USE telegraf
Run the command SELECT * INTO UPS..APC FROM telegraf..APC group by *
Run the command DROP DATABASE telegraf
Exit the container with exit

Note: APC is from the curl command in the script I used in the UPS guide
If you called the table something else you need to change it to that.

[email protected]:~# docker exec -it InfluxdbUPS bash
[email protected]:/# influx
Connected to http://localhost:8086 version 1.5.4
InfluxDB shell version: 1.5.4
> show databases
name: databases
> use telegraf
Using database telegraf
> SELECT * INTO UPS..APC FROM telegraf..APC group by *
name: result
time written
---- -------
0 377424
> DROP DATABASE telegraf
> exit

After removing the telegraf data my InfluxdbUPS appdata folder, the size went from 15GB to 57MB!

[email protected]:/mnt/cache/Docker/influxdbups# du -sh
15G     .
[email protected]:/mnt/cache/Docker/influxdbups# du -sh
57M     .


Go to user scripts settings and copy the old script
Edit the script to send data to the new influxdbUPS container and remember to change the database to UPS or the name you chose for it.
Add the custom schedule * * * * * and click apply
Then click on run script in background.


Add a new data source and call it Influx UPS
Add your URL to the new container and set the database to UPS

Go to your UPS dashboard and edit a panel.
Change data source to confirm that the new script is working.

If you see that the old data is still there and that it gets updated with new data it works!
Now you can change the data source on all the different panels.

Note: I will for the time being still be running the old script just in case something is messed up.



For any questions you can find me here:


How to setup Cloudflare and fail2ban with automated “set_real_ip_from” in nginx Monitoring your UPS stats and cost with InfluxDB and Grafana on Unraid – Telegraf Edition Visualizing Nginx geo data metrics  with Python, InfluxDB and Grafana on the linuxserver letsencrypt/swag container