首页 > 其他分享 >influxdb得导出与导入

influxdb得导出与导入

时间:2024-07-13 21:41:41浏览次数:8  
标签:rp db 备份 导出 shard influxdb 导入 InfluxDB backup

转载请注明出处:

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

 

 

标签:rp,db,备份,导出,shard,influxdb,导入,InfluxDB,backup
From: https://www.cnblogs.com/zjdxr-up/p/18300776

相关文章

  • 导入Excel大量数据如何优化
    导入Excel大量数据如何优化背景线上导入excel的时候发现速度太慢了发现原来的代码是读入所有数据然后按行去数据库比对是否存在,不存在再插入。这样就相当于n条数据要有2n次的数据库请求,以前数据量小的时候没问题,数据量一大就暴露出问题了,下面的测试在数据库......
  • 导出记录xls_or_csv文件
    文章目录前言操作文件流式1.设定请求2.组装数据3.创建文件导出数据Excel文件POIEasyExcel纯文本格式数据csvTips:4.OSS创建桶endpointpath秘钥主账号子账号上传方法效果配置权限最后前言这是一个提供后台数据导出的方案。在我们业务场景的时候,需要对于......
  • CCS工程导入后编译时无法读取头文件的问题
    CCS工程导入后编译时无法读取头文件的问题,主要是由移植之后的文件搜索路径所指向的文件夹不存在导致的。有两种解决办法:①导入工程时将所需要的所有.h、.c以及.lib文件一并打包在工程文件中,复制到Workspace并重新选取搜索路径;②导入工程的电脑安装有C2000WARE,修改CCS中相对路径......
  • 生成带logo二维码+批量压缩导出
    importcom.google.zxing.BarcodeFormat;importcom.google.zxing.EncodeHintType;importcom.google.zxing.MultiFormatWriter;importcom.google.zxing.common.BitMatrix;importcom.google.zxing.qrcode.decoder.ErrorCorrectionLevel;importjavax.imageio.ImageIO;......
  • pandas导出excel
    工具类cvsutil.py#!/usr/bin/envpython#-*-coding:utf-8-*-importcsvimportcodecsimportioclassUTF8Recoder:"""IteratorthatreadsanencodedstreamandreencodestheinputtoUTF-8"""def__init_......
  • python项目导入上级目录设置”的setting.json是不是哪里还有错误呀?
    大家好,我是Python进阶者。一、前言前几天在Python白银交流群【王者级混子】问了一个Python代码处理的问题,问题如下:大佬们,我想问问我抄网上“vscode运行python项目导入上级目录设置”的setting.json是不是哪里还有错误呀?还是没法导入上级目录二、实现过程这里后来很快他自己找......
  • insert into....select从一个数据库的表中导入到另一个数据库的表中
    说明已知条件:有两台oracle数据库,ora1和ora2,ora1的表中有数据(ip:192.0.0.1,表名table1,用户名和密码:yth(有管理员的权限),数据库服务名:orcl),需要导入ora2中(ip:192.0.0.2,表名table2,用户名和密码:ythcj(有管理员的权限),数据库服务名:orcl)。1.在ora2中建立数据库的链接指向ora1(需要有管理员......
  • POI导出案例
    /** *POI方式导出 *@paramlist数据 *@paramexportFields绑定列数组,0:表头,1:数据key *@paramresponse */ publicstaticvoidexportExcel(Listlist,String[]exportFields,HttpServletResponseresponse){ Workbookwb=newXSSFWorkbook(); /......
  • java导出PDF文件
    我们需要将生成的PDF文件直接导出到浏览器而不是保存到本地,需要对HttpServletResponse进行配置,将PDF写入到响应流中。以下是可以将PDF导出到浏览器进行下载:我们首先先编写PDF工具类:packagecom.scenic.util;importcom.itextpdf.text.*;importcom.itextpdf.text.pdf.*;im......
  • Lbview调用python脚本报错:错误1667...无法导入指定的python模块
    前提注意:NILabVIEW2021(32位)Python3.9.10(32位)32位对应32位,64位同理,否则可能会报错报错的原因:LabVIEW中使用的Python环境与安装的Python包不匹配也就是说Labview中使用的是python版本安装的系统路径,而PyCharm使用的虚拟环境路径,它的包都是下载到项目文件夹内可......