Backup and Restore InfluxDB databases
276 words, 2 minutes
Once upon a time, the collectd database was hosted on the dagobah InfluxDB 1.4.x server. Then came the moment when it had to be migrated to the hoth server. The backup and restore process happened this way…
On the source server, enable remote management for InfluxDB:
# vi /etc/influxdb/influxdb.conf
(...)
bind-address = "0.0.0.0:8088"
# rcctl restart influxdb
On the destination server, dump the source database :
# influxd backup -database collectd -host 192.168.0.128:8088 .
<em>2018/04/04 09:54:55 backing up db=collectd since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:54:55 backing up metastore to meta.00
2018/04/04 09:54:55 backing up db=collectd rp=autogen shard=2 to collectd.autogen.00002.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:54:57 backing up db=collectd rp=autogen shard=8 to collectd.autogen.00008.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:06 backing up db=collectd rp=autogen shard=16 to collectd.autogen.00016.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:14 backing up db=collectd rp=autogen shard=24 to collectd.autogen.00024.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:25 backing up db=collectd rp=autogen shard=32 to collectd.autogen.00032.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:33 backing up db=collectd rp=autogen shard=40 to collectd.autogen.00040.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:43 backing up db=collectd rp=autogen shard=48 to collectd.autogen.00048.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:52 backing up db=collectd rp=autogen shard=56 to collectd.autogen.00056.00 since 0001-01-01 00:00:00 +0000 UTC
2018/04/04 09:55:55 backup complete</em>
To restore the backup, the destination InfluxDB daemon has to be stopped. Then, import the data:
# service influxd stop
# influxd restore -metadir /var/db/influxdb/meta -datadir /var/db/influxdb/data -database collectd .
Using metastore snapshot: meta.00
Restoring from backup collectd.*
unpacking /var/db/influxdb/data/collectd/autogen/2/000000001-000000001.tsm
unpacking /var/db/influxdb/data/collectd/autogen/8/000000004-000000004.tsm
unpacking /var/db/influxdb/data/collectd/autogen/16/000000004-000000004.tsm
unpacking /var/db/influxdb/data/collectd/autogen/24/000000004-000000004.tsm
unpacking /var/db/influxdb/data/collectd/autogen/32/000000004-000000003.tsm
unpacking /var/db/influxdb/data/collectd/autogen/40/000000006-000000002.tsm
unpacking /var/db/influxdb/data/collectd/autogen/48/000000006-000000002.tsm
unpacking /var/db/influxdb/data/collectd/autogen/56/000000003-000000002.tsm
unpacking /var/db/influxdb/data/collectd/autogen/56/000000004-000000001.tsm
unpacking /var/db/influxdb/data/collectd/autogen/56/000000005-000000001.tsm
# chown -R influxd:influxd /var/db/influxdb
# service influxd start
Et voilĂ .