InfluxDB is a great Database for Time-Series use cases and it has found its way into the IOT domain. This article will talk about how to migrate your data from one InfluxDB instance to another.
We will first Backup our database, make a Tarball and finally Restore the database to new instance of InfluxDB.
Check Out : How to Setup InfluxDB instance
Steps to Backup and Restore Influx DB
There are 2 components of every influxDB instance :
- Metadata: It stores the info about all databases, its measurements and tags
- Data: It stores actual data for a Database
Step 1: Backup Database
We need to create a backup of our Database
influxd backup -database [DATABASE NAME] <PATH-TO-BACKUP> # Backup Metadata influxd backup . # Backup Data (includes metadata) influxd backup -database indooroutdoorenvdata .
Step 2: Move data from one computer to another
We need to zip the data and move it to our destination server.
# Zip the Data tar -czvf file.tar.gz <PATH-TO-STORE> # Unzip the data tar -xzvf file.tar.gz # To move the data between different server you can use sftp sftp firstname.lastname@example.org # Then use put/get to move the data
Step 3: Restore the Database
# Restore the database by giving the path to metadir and datadir (from config files) sudo influxd restore -database indooroutdoorenvdata -metadir /var/lib/influxdb/meta -datadir /var/lib/influxdb/data . # Need to change permission for imported files sudo chown -R influxdb:influxdb /var/lib/influxdb
Step 4: Restart the Database
sudo systemctl stop influxdb sudo systemctl start influxdb sudo systemctl status influxdb
After this your Databases will be visible in InfluxDB console. If you had more than 1 DB, then all your DBs will be shown but data will be present only for the DB which you Backup-ed.