介紹
InfluxDB自帶influxd命令同樣支持數據備份和恢復,備份的時候分爲meta、manifest、數據;下面介紹下實際操作
1.導出本機數據備份
備份數據庫:monitordb
備份存儲目錄位置:/data/backup
influxd backup -portable -database monitordb /data/backup
指定遠程主機備份參數
• -host 192.168.1.6:8086
• -database monitordb #指定要備份數據庫,如不指定默認全部
• -portable #兼容更新版本influxdb的備份文件格式,官方建議使用
• -start <timestamp>#指定需備份數據開始時間戳-start 2015-12-24T08:12:23Z
• -end <timestamp> #結束時間戳 -end 2015-12-31T08:12:23Z
2.導出遠程主機備份
influxd backup -portable -database zabbix -host 192.168.1.5:8088 /data/backup
2018/11/24 17:52:58 backing up metastore to /data/backup/meta.00
2018/11/24 17:52:58 backing up db=zabbix
2018/11/24 17:52:58 backing up db=zabbix rp=autogen shard=2 to /data/backup/zabbix.autogen.00002.00 since 0001-01-01T00:00:00Z
2018/11/24 17:52:58 backup complete:
2018/11/24 17:52:58 /data/backup/20181124T095258Z.meta
2018/11/24 17:52:58 /data/backup/20181124T095258Z.s2.tar.gz
2018/11/24 17:52:58 /data/backup/20181124T095258Z.manifest
3.恢復數據
恢復本地數據
influxd restore -portable -db zabbix /data/backup/
2018/11/26 05:03:42 Restoring shard 8 live from backup 20181125T205756Z.s8.tar.gz
查看恢復數據
> show series
key
---
cpu,host=serverA,region=ca_east
cpu,host=serverA,region=us_west
> show measurements
name: measurements
name
----
cpu
> show tag keys
name: cpu
tagKey
------
host
region
> show field keys
name: cpu
fieldKey fieldType
-------- ---------
value float
> select * from zabbix
> select * from cpu
name: cpu
time host region value
---- ---- ------ -----
1543042396476461820 serverA us_west 0.64
1543042713994239023 serverA ca_east 0.99