• influxdb得导出与导入


    转载请注明出处:

    1、备份元数据

      基本语法:

    influxd backup 

      备份元数据,没有任何其他参数,备份将只转移当前状态的系统元数据到path-to-backuppath-to-backup为备份保存的目录,不存在会自动创建。

      该备份会备份所有数据库以及所有保存策略下得数据。

       导出常用得其他参数:

    复制代码
    root@704be48ac1bc:/# influxd backup -h
    
    Creates a backup copy of specified InfluxDB OSS database(s) and saves the files in an Enterprise-compatible
    format to PATH (directory where backups are saved).
    
    Usage: influxd backup [options] PATH
    
        -portable
                Required to generate backup files in a portable format that can be restored to InfluxDB OSS or InfluxDB
                Enterprise. Use unless the legacy backup is required.
        -host 
                InfluxDB OSS host to back up from. Optional. Defaults to 127.0.0.1:8088.
        -db 
                InfluxDB OSS database name to back up. Optional. If not specified, all databases are backed up when
                using '-portable'.
        -rp 
                Retention policy to use for the backup. Optional. If not specified, all retention policies are used by
                default.
        -shard 
                The identifier of the shard to back up. Optional. If specified, '-rp ' is required.
        -start <2015-12-24T08:12:23Z>
                Include all points starting with specified timestamp (RFC3339 format).
                Not compatible with '-since '.
        -end <2015-12-24T08:12:23Z>
                Exclude all points after timestamp (RFC3339 format).
                Not compatible with '-since '.
        -since <2015-12-24T08:12:23Z>
                Create an incremental backup of all points after the timestamp (RFC3339 format). Optional.
                Recommend using '-start ' instead.
        -skip-errors
                Optional flag to continue backing up the remaining shards when the current shard fails to backup.
    backup: flag: help requested
    复制代码

      具体如下:

    复制代码
    Usage: influxd backup [options] PATH
        -portable   # 在线备份,必选
        -host  # 需要备份的influxdb服务机器地址,可选,Defaults to 127.0.0.1:8088.
        -db  # 需要备份的db名称,可选,若没有指定,将备份所有数据库
        -rp  # 备份某个保留策略的数据,未指定,则备份所有rp的数据。
        -shard  # 需要备份的shard id,可选,若指定了备份shard,必须先选择rp
        -start # 需要备份的数据的起始时间,timestamp (RFC3339 format). 不能和-since一起使用
        -end # 需要备份的数据的结束时间,timestamp (RFC3339 format). 不能和-since一起使用
        -since # 备份这个timestamp之后的数据,建议用-start 代替
        -skip-errors # 可选,当备份shards时,跳过备份失败的shard,继续备份其他shard。
    复制代码

     

    2.influxdb导入

      1.先删除数据库

                               

      2.导入备份数据:

                   

       这种方式只能导入按个数据库进行导入;

      3.导入其他配置项参数:

    复制代码
    root@704be48ac1bc:/# influxd restore -h
    
    Uses backup copies from the specified PATH to restore databases or specific shards from InfluxDB OSS
      or InfluxDB Enterprise to an InfluxDB OSS instance.
    
    Usage: influxd restore -portable [options] PATH
    
    Note: Restore using the '-portable' option consumes files in an improved Enterprise-compatible
      format that includes a file manifest.
    
    Options:
        -portable
                Required to activate the portable restore mode. If not specified, the legacy restore mode is used.
        -host  
                InfluxDB OSS host to connect to where the data will be restored. Defaults to '127.0.0.1:8088'.
        -db    
                Name of database to be restored from the backup (InfluxDB OSS or InfluxDB Enterprise)
        -newdb 
                Name of the InfluxDB OSS database into which the archived data will be imported on the target system.
                Optional. If not given, then the value of '-db ' is used.  The new database name must be unique
                to the target system.
        -rp    
                Name of retention policy from the backup that will be restored. Optional.
                Requires that '-db ' is specified.
        -newrp 
                Name of the retention policy to be created on the target system. Optional. Requires that '-rp '
                is set. If not given, the '-rp ' value is used.
        -shard 
                Identifier of the shard to be restored. Optional. If specified, then '-db ' and '-rp ' are
                required.
        PATH
                Path to directory containing the backup files.
    
    restore: flag: help requested
    复制代码

      主要作用:

    复制代码
    Usage: influxd restore -portable [options] PATH
    Options:
        -portable #
        -host  
        -db     # 从备份数据的哪个库恢复数据Name of database to be restored from the backup
        -newdb 
                # 数据恢复到新库名称,若没有指定,选择-db 的名称。newdb必须不存在,恢复时会自动创建
        -rp     # 从备份数据的哪个rp恢复数据,指定了-rp,必须指定-db
        -newrp  #恢复数据新的rp名称,newrp必须存在。指定了-rp,未指定-newrp则使用-rp
        -shard  # 需要恢复的shard,如果指定了'-db ' and '-rp ',必须-shard
        PATH #备份数据文件list
    复制代码

      4.第二种导入方式:

      删除influxdb数据库存储得元数据文件,将influxdb得数据库元文件目录指定为备份得目录,然后再重启influxdb数据库即可完成导入

    influxd restore -metadir  

      从/var/lib/influxdb/ 目录下删除meta目录,即 rm -rf /var/lib/influxdb/meta,然后重启influxdbservice influxdb restart

     

     

  • 相关阅读:
    绝了,让你快速搭建SpringWeb应用和精通MVC架构,啃完就知道有多好用了
    解析生成式人工智能 | 它真的有这么强大吗?
    【CSS应用篇】——CSS如何实现圆角边框
    Bootstrap实例累积
    TiDB-PCTP考试复习
    快速排序的实现!递归实现!!超详细!!!
    Close 和 Dispose 方法到底有什么不同?
    【JavaEE重点知识归纳】第5节:方法
    1200PLC和Modbus485主站DCS系统通讯
    Qt QtCreator 所有官方下载地址
  • 原文地址:https://www.cnblogs.com/zjdxr-up/p/18300776