InfluxDB 2.x: Backup and Restore: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
 
(10 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
''Info: You can run a backup/restore while sending and writing data to the same buckets. The data will not replaced from restore.''
 +
 +
 
== Backup ==
 
== Backup ==
 
<source lang="bash">
 
<source lang="bash">
Zeile 19: Zeile 22:
  
 
== Compress & move Backup ==
 
== Compress & move Backup ==
 +
<source lang="bash">
 +
#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>:/<DESTINATION_PATH>
 +
</source>
  
  
 
== Restore ==
 
== Restore ==
 
=== Prepare archive for restore ===
 
=== Prepare archive for restore ===
 +
<source lang="bash">
 +
#Change user to root
 +
sudo su -
 +
 +
#Change owner of the Backupfile
 +
cd /<DESTINATION_PATH>
 +
chown -R influxdb:influxdb bkr_full_<TIMESTAMP>.tar
 +
 +
#Change user
 +
sudo su - influxdb
 +
 +
#Unpack the archive
 +
tar -xf bkr_full_<TIMESTAMP>.tar
 +
</source>
  
 
=== Restore the Backup ===
 
=== Restore the Backup ===
 +
<source lang="bash">
 +
#Export environment variables
 +
export INFLUX_CONFIGS_PATH=<PATH_TO_THE_CONFIG>
 +
export INFLUX_TOKEN=<INFLUXDB_ADMIN_TOKEN>
 +
 +
#Check InfluxDB connection
 +
influx config ls
 +
 +
#Start restore
 +
influx restore --full <PATH_TO_BACKUPFILE>/bkr_full_<TIMESTAMP>
 +
 +
#Check if restore is running with htop
 +
htop
 +
</source>
 +
 +
=== Restore hangs ===
 +
If there restore hangs restart the InfluxDB service:
 +
<source lang="bash">
 +
#Restart InfluxDB service
 +
systemctl restart influxdb.service
 +
 +
#Check status
 +
systemctl status influxdb.service
 +
</source>
  
  
  
  
 +
'''More information's:''' <br>
 +
*'''Backup:''' https://docs.influxdata.com/influxdb/v2.0/reference/cli/influx/backup/ <br>
 +
*'''Restore:''' https://docs.influxdata.com/influxdb/v2.0/reference/cli/influx/restore/
  
  

Aktuelle Version vom 17. März 2021, 16:48 Uhr

Info: You can run a backup/restore while sending and writing data to the same buckets. The data will not replaced from restore.


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>:/<DESTINATION_PATH>


Restore

Prepare archive for restore

#Change user to root
sudo su -
 
#Change owner of the Backupfile
cd /<DESTINATION_PATH>
chown -R influxdb:influxdb bkr_full_<TIMESTAMP>.tar
 
#Change user
sudo su - influxdb
 
#Unpack the archive
tar -xf bkr_full_<TIMESTAMP>.tar

Restore the Backup

#Export environment variables
export INFLUX_CONFIGS_PATH=<PATH_TO_THE_CONFIG>
export INFLUX_TOKEN=<INFLUXDB_ADMIN_TOKEN>
 
#Check InfluxDB connection
influx config ls
 
#Start restore
influx restore --full <PATH_TO_BACKUPFILE>/bkr_full_<TIMESTAMP>
 
#Check if restore is running with htop
htop

Restore hangs

If there restore hangs restart the InfluxDB service:

#Restart InfluxDB service
systemctl restart influxdb.service
 
#Check status
systemctl status influxdb.service



More information's: