180727-time Series database Influxdb backup and recovery strategy

Source: Internet
Author: User
Tags influxdb

Influxdb Backup and Recovery

Reference: Influxdb Backup and restore

Environment:

    • Influxdb v1.6.0
    • Using the influx automatic console
I. Backup

Backup command

influxd backup    [ -database <db_name> ]  --> 指定需要备份的数据库名    [ -portable ]            --> 表示在线备份    [ -host 
1. Example Demo

First create a database Yhhblog, which contains two measurement, the corresponding data is as follows

> show databasesname: databasesname----_internalyhhblog> use yhhblogUsing database yhhblog> show measurementsname: measurementsname----netLoadserviceLoad> select * from netLoadname: netLoadtime                host      netIn netOut service----                ----      ----- ------ -------1532658769048100401 127.0.0.1 13m   521K   app.service.about> select * from serviceLoadname: serviceLoadtime                cpu   host      load mem   qps  rt   service----                ---   ----      ---- ---   ---  --   -------1532658713805369067 45.23 127.0.0.2 1.21 4145m 1341 1312 app.service.about1532658718726259226 45.23 127.0.0.1 1.21 4145m 1341 1312 app.service.about
A. Backing up all databases

Back up all the databases in the Influxdb, without any parameters

influxd backup -portable /tmp/data/total
B. Backing up a specified database

If you only want to back up the Yhhblog database above, add a -database parameter to specify

# influxd backup -portable -database yhhblog /tmp/data/yhhblog2018/07/27 10:38:15 backing up metastore to /tmp/data/yhhblog/meta.002018/07/27 10:38:15 backing up db=yhhblog2018/07/27 10:38:15 backing up db=yhhblog rp=autogen shard=10 to /tmp/data/yhhblog/yhhblog.autogen.00010.00 since 0001-01-01T00:00:00Z2018/07/27 10:38:15 backup complete:2018/07/27 10:38:15     /tmp/data/yhhblog/20180727T023815Z.meta2018/07/27 10:38:15     /tmp/data/yhhblog/20180727T023815Z.s10.tar.gz2018/07/27 10:38:15     /tmp/data/yhhblog/20180727T023815Z.manifest
C. Backing up data for a specified time period in a database

For the above data, only part of the time to meet the requirements of the data, you can add start/end parameters

# influxd backup -portable -database yhhblog -start 2018-07-27T2:31:57Z -end 2018-07-27T2:32:59Z  /tmp/data/yhhblog_per2018/07/27 10:42:14 backing up metastore to /tmp/data/yhhblog_per/meta.002018/07/27 10:42:14 backing up db=yhhblog2018/07/27 10:42:14 backing up db=yhhblog rp=autogen shard=10 to /tmp/data/yhhblog_per/yhhblog.autogen.00010.00 with boundaries start=2018-07-27T02:31:57Z, end=2018-07-27T02:32:59Z2018/07/27 10:42:14 backup complete:2018/07/27 10:42:14     /tmp/data/yhhblog_per/20180727T024214Z.meta2018/07/27 10:42:14     /tmp/data/yhhblog_per/20180727T024214Z.s10.tar.gz2018/07/27 10:42:14     /tmp/data/yhhblog_per/20180727T024214Z.manifest

Backup OK now, the question is how to confirm the backup problem, how to recover the data after backup?

II. Recovery

The command is as follows

influxd restore     [ -db <db_name> ]       --> 待恢复的数据库(备份中的数据库名)    -portable | -online    [ -host 

First, take a simple way to demonstrate the recovery strategy and see if there is a problem with the backup data above

1. Restore to a non-existent database

Following the demo below to restore the previous exported backup to a new database YHHBLOG_BK, execute the following command

influxd restore -portable -db yhhblog -newdb yhhblog_bk yhhblog_per

Incidentally verify that there is a problem with the data backed up above, noting that we are recovering data from a time fragment, so the recovered data should be excluded from the data that is no longer in the date above

> show databasesname: databasesname----_internalyhhblogyhhblog_bk> use yhhblog_bkUsing database yhhblog_bk> show measurementsname: measurementsname----netLoadserviceLoad> select * from netLoadname: netLoadtime                host      netIn netOut service----                ----      ----- ------ -------1532658769048100401 127.0.0.1 13m   521K   app.service.about> select * from serviceLoadname: serviceLoadtime                cpu   host      load mem   qps  rt   service----                ---   ----      ---- ---   ---  --   -------1532658718726259226 45.23 127.0.0.1 1.21 4145m 1341 1312 app.service.about

Note that there is only one piece of data in the front serviceload, which means we're back in time.

2. Restore to the existing DB

In the Crossing Network recovery document, if you want to restore the backup to an existing database, it is not as simple as above, one strategy is to use XI ' an to backup to a temporary DB, and then write the data in the temporary DB to the existing DB

The specific demonstration steps are as follows (note that the execution of this summary can be directly dependent on the previously restored backup database)

Restore a backup to an existing database yhhblognew

# 首先是将备份恢复到一个不存在的数据库 yhhblog_bk 中influxd restore -portable -db yhhblog -newdb yhhblog_bk yhhblog_per

Go to the influx console, perform a copy and delete the staging database

# 准备 yhhblogNew 数据库> create database yhhblogNew# 将临时数据库中的数据导入已存在的数据库中> use yhhblog_bk> SELECT * INTO yhhblogNew..:MEASUREMENT FROM /.*/ GROUP BY *> drop yhhblog_bk
3. When a retention policy already exists, the recovery
influxd restore -portable -db yhhblog -newdb yhhblog_tmp -rp autogen -newrp autogen_tmp  yhhblog

Enter the influx console to perform the copy

> user yhhblog_tmp> SELECT * INTO yhhblogNew.autogen.:MEASUREMENT FROM /yhhblog_tmp.autogen_tmp.*/ GROUP BY *> drop database yhhblog_tmp
4. Other

The official also wrote two other kinds of recovery methods, one is discarded, an offline will cause data loss, and is not recommended, and now most of the blog post backup and recovery is this outdated scheme, not very friendly, here is not detailed description

Iii. other 1. A grey and grey blog:https://liuyueyi.github.io/hexblog

A gray and gray personal blog, recording all the study and work in the blog, welcome everyone to visit

2. Disclaimer

The letter is not as good as, has been on the content, purely opinion, because of limited personal ability, inevitably there are omissions and errors, such as the detection of bugs or better suggestions, welcome criticism, please feel grateful

    • Weibo address: small Gray Gray Blog
    • QQ: A grey/grey/3302797840
3. Scan for attention

Small grey ash blog& public number

Knowledge Planet

180727-time Series database Influxdb backup and recovery strategy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.