influxdb得导出与导入

简介: influxdb得导出与导入

转载请注明出处:

1、备份元数据

  基本语法:

influxd backup <path-to-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 <host:port>
            InfluxDB OSS host to back up from. Optional. Defaults to 127.0.0.1:8088.
    -db <name>
            InfluxDB OSS database name to back up. Optional. If not specified, all databases are backed up when
            using '-portable'.
    -rp <name>
            Retention policy to use for the backup. Optional. If not specified, all retention policies are used by
            default.
    -shard <id>
            The identifier of the shard to back up. Optional. If specified, '-rp <rp_name>' is required.
    -start <2015-12-24T08:12:23Z>
            Include all points starting with specified timestamp (RFC3339 format).
            Not compatible with '-since <timestamp>'.
    -end <2015-12-24T08:12:23Z>
            Exclude all points after timestamp (RFC3339 format).
            Not compatible with '-since <timestamp>'.
    -since <2015-12-24T08:12:23Z>
            Create an incremental backup of all points after the timestamp (RFC3339 format). Optional.
            Recommend using '-start <timestamp>' 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 <host:port> # 需要备份的influxdb服务机器地址,可选,Defaults to 127.0.0.1:8088.
    -db <name> # 需要备份的db名称,可选,若没有指定,将备份所有数据库
    -rp <name> # 备份某个保留策略的数据,未指定,则备份所有rp的数据。
    -shard <id> # 需要备份的shard id,可选,若指定了备份shard,必须先选择rp
    -start # 需要备份的数据的起始时间,timestamp (RFC3339 format). 不能和-since一起使用
    -end # 需要备份的数据的结束时间,timestamp (RFC3339 format). 不能和-since一起使用
    -since # 备份这个timestamp之后的数据,建议用-start <timestamp>代替
    -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  <host:port>
            InfluxDB OSS host to connect to where the data will be restored. Defaults to '127.0.0.1:8088'.
    -db    <name>
            Name of database to be restored from the backup (InfluxDB OSS or InfluxDB Enterprise)
    -newdb <name>
            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 <db_name>' is used.  The new database name must be unique
            to the target system.
    -rp    <name>
            Name of retention policy from the backup that will be restored. Optional.
            Requires that '-db <db_name>' is specified.
    -newrp <name>
            Name of the retention policy to be created on the target system. Optional. Requires that '-rp <rp_name>'
            is set. If not given, the '-rp <rp_name>' value is used.
    -shard <id>
            Identifier of the shard to be restored. Optional. If specified, then '-db <db_name>' and '-rp <rp_name>' are
            required.
    PATH
            Path to directory containing the backup files.
restore: flag: help requested

  主要作用:

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

  4.第二种导入方式:

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

influxd restore -metadir <path-to-meta-or-data-directory> <path-to-backup>

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


 

标签: influxdb

目录
相关文章
|
5月前
|
JSON NoSQL 小程序
Mongodb数据库的导出和导入总结
Mongodb数据库的导出和导入总结
271 0
|
JSON NoSQL 关系型数据库
MongoDB数据的导入与导出
MongoDB数据的导入与导出
640 0
|
1月前
|
SQL C# 数据库
EPPlus库的安装和使用 C# 中 Excel的导入和导出
本文介绍了如何使用EPPlus库在C#中实现Excel的导入和导出功能。首先,通过NuGet包管理器安装EPPlus库,然后提供了将DataGridView数据导出到Excel的步骤和代码示例,包括将DataGridView转换为DataTable和使用EPPlus将DataTable导出为Excel文件。接着,介绍了如何将Excel数据导入到数据库中,包括读取Excel文件、解析数据、执行SQL插入操作。
EPPlus库的安装和使用 C# 中 Excel的导入和导出
|
1月前
|
JSON NoSQL MongoDB
MongoDB批量导出导入操作的示例
使用 `mongoexport`和 `mongoimport`工具可以方便地对MongoDB数据库进行批量数据的导出和导入操作。它们支持多种格式和灵活的选项,使得数据迁移、备份和同步变得简单快捷。在实际应用中,根据具体的需求和数据特性选择合适的命令和选项是非常重要的,这将确保数据处理的效率和准确性。
51 1
|
5月前
|
存储 Java easyexcel
导出导入开发场景
导出导入开发场景
|
5月前
|
JSON NoSQL MongoDB
mongoDB数据的导出导入
mongoDB数据的导出导入
145 0
|
5月前
|
JSON NoSQL MongoDB
Mongo的导出和导入(mongoexport和mongoimport)
Mongo的导出和导入(mongoexport和mongoimport)
|
SQL 运维 关系型数据库
|
SQL 算法 关系型数据库
|
SQL Oracle Cloud Native