InfluxDB 2.x: Backup and Restore

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche

Backup

#Change user
sudo su - influxdb
 
#Export environment variables
export INFLUX_TOKEN=<INFLUXDB_ADMIN_TOKEN>
export INFLUX_CONFIGS_PATH=~/profile
export TIME=$(date + "%Y%m%d%H%M%S")
export BKR_DEST=/var/lib/influxdb/backup
 
#Check InfluxDB connection
influx config ls
 
#Start Backup
influx backup $BKR_DEST/bkr_full_$TIME


Compress & move Backup

#Compress
tar -cf bkr_full_$TIME.tar bkr_full_$TIME
 
#Copy the Backupfile to destination
rsync -aP /var/lib/influxdb/backup/bkr_full_$TIME.tar <YOUR_USERNAME>@<DESTINATION_HOST>:/<PATH>


Restore

Prepare archive for restore

Restore the Backup