Hi,
I´m using HA on a Raspi4 running HASSOS 3.8. Influxdb on the raspi handles my sensor data and does that very well. However, I want to move the DB to another server. How can I dump everything to a file (that I can access, hello Docker) to be able to import it into my new server ?
Did you ever find out what’s the best procedure? Would be interested in doing the same.
Sadly, no…
If you’re using the same architecture on both servers you can do a partial snapshot for a single addon and then restore on the second one.
Managed to do this, wasn’t very complicated in the end.
The influxdb addon doesn’t have the required ports open, so remote backup is not supported. The only way I could figure out is to login to the docker container, make local backup, snapshot in hassio…
- Install portainer addon and disable protection mode
- Open portainer, remove addons from the hidden containers list in portainer settings
- Open exec console to influx addon, backup the database locally in the container
influxd backup -portable -database hassio -host <local host>:8086 /data/<filename>
(maybe host was not require…) - Create new snapshot in supervisor, find the backup file, move to new system
- Restore to new database
influxd restore -portable /data/<filename>
- Create matching username and pass in new influx
- Update configuration.yaml with new IP
- Stop the addon influxdb and disable autostart
(9. change samba backup frequency from daily to weekly)
For influx installation in the remote machine I used this
https://hub.docker.com/r/philhawthorne/docker-influxdb-grafana/
I, i had no time to try… This solution will work well even to have an influxdb database backup to use on the same machine in case homeassistant or influxdb itself failure?
To see if i understand, to save a backup of homeassistant that contains even an influxdb database backup:
- Using portainer save a local influxdb db backup.
- Do an homeassistant snapshot: now this snapshot contains even influx database backup, is this right?
To restore in case homeassistant or influxdb failure:
- Restore previous saved homeassistant snapshot
- Using portainer restore saved influx database local backup.
Is all right?
Yes, should work like that. Although if you take the snapshot like you describe with the intention to restore it back to hassio addon (like the snapshot is intended), I don’t see a reason why. The backup inside the snapshot would essentially be a backup of a backup.
I guess restoring from the snapshot to completely separate database would somehow be possible even without the additional backup step as well. I just didn’t have the energy to figure out how. The data surely should be there.
I think this works and is remarkably simple (happy for someone to tell me I’m wrong).
First find the containerID number
sudo docker ps --format "table {{.ID}}\t{{.Names}}" | grep influx
Then run an influxdb backup, putting the files into the share folder
sudo docker exec <containerID> influxd backup -portable -database <database name> "/share/influxbackup/database-name"
The backup will now be in
/usr/share/hassio/share/influxbackup/database-name
Seems too easy
[edit]
This backs up all the databases.
sudo docker exec <containerID> influxd backup -portable "/share/influxdb.backup"
Sorry for bringing this thread back to life, but I found @baz123 answer for backup helpful- thought I would expand to include MariaDB backup. (since that on my list)
Find container ID
sudo docker ps --format "table {{.ID}}\t{{.Names}}" | grep maria
create backup folder
mkdir /share/mariadb.backup/
run dump on single db
sudo docker exec <containerID> mysqldump --user=<mariadb username> --password=<mariadb password> --lock-tables --databases <maria database name> /share/mariadb.backup/mariadb_backup.sql
dump all dbases
sudo docker exec <containerID> mysqldump --user=<mariadb username> --password=<mariadb password> --lock-tables --all-databases /share/mariadb.backup/mariadb_backup.sql
Only easy because of your help, @baz123 Many thanks!
Hi, is it possible to export influxdb database backup from influxdb haos addon?
That is what my solution above does