influxdb: backup and restore on Ubuntu 18.04

I ran into some trouble trying to backup and restore a InfluxDB to a new server. Here are the steps to correctly backup a database and restore it on the remote host.

On the source host, backup the InfluxDB you want while the influxdb is running:

# This will create a directory "backup" for DATABASE_NAME:
influxd backup -database DATABASE_NAME backup

Transfer the directory to the target machine and import the data (using default directories from influx):

sudo service influxdb stop # Restore works ONLY on stopped InfluxDB
sudo influxd restore -metadir /var/lib/influxdb/meta BACKUP_DIRECTORY
sudo influxd restore -database DATABASE_NAME -datadir /var/lib/influxdb/data BACKUP_DIRECTORY
sudo chown -R influxdb:influxdb /var/lib/influxdb
sudo service influxdb start

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.