ES和MONGODB备份脚本

ES:

使用elasticdump备份:

###URL取svc: elasticsearch-masterd的 clusterip/9200

for item in (curl 'http://'URL'/_cat/indices' | awk '{print $3}' | grep -E "要备份的索引名称" )

do

echo mapping $item

elasticdump --input=http://$URL/$item --output=DIR/item'-mapping.json' --limit=1000 --type=mapping

echo settings $item

elasticdump --input=http://$URL/$item --output=DIR/item'-settings.json' --limit=1000 --type=settings

echo alias $item

elasticdump --input=http://$URL/$item --output=DIR/item'-alias.json' --type=alias

echo data $item

elasticdump --input=http://$URL/$item --output=DIR/item'-data.json' --limit=1000 --type=data

done

MONGODB:

使用mongodump备份全库数据

特别注意备份全库数据一定要在mongos 路由pod下进行,不要在分片的pod下进行;

1、进入mongos 路由pod执行全库备份命令

kubectl exec -it -n $namespace mongodb-mongodb-sharded-mongos-xxx -- /bin/bash

开始备份:mongodump --host mongodb-mongodb-sharded-headless --port 27017 \

-uroot -pkgclite \

--authenticationDatabase="admin" \

--out /tmp/backup

2、将备份的数据打包并拷贝到宿主机

cd /tmp

tar -zcvf mongodb_bakup.tar.gz backup

#退出容器:exit

kubectl cp -n {namepsace} {mongos路由pod名称}:/tmp/mongodb_bakup.tar.gz mongodb_bakup.tar.gz

相关推荐
-一杯为品-6 小时前
【STM32单片机】#4 OLED调试&外部中断
stm32·单片机·mongodb
柒月玖.18 小时前
基于AT89C52单片机的轮胎压力监测系统
单片机·嵌入式硬件·mongodb
啞謎专家1 天前
在rockylinux9.4安装mongodb报错:缺少:libcrypto.so.10文件库
数据库·mongodb
算家云1 天前
Ubuntu 22.04安装MongoDB:GLM4模型对话数据收集与微调教程
大数据·人工智能·mongodb·ubuntu·elasticsearch·算家云·glm4微调
陈阳羽2 天前
云服务器Ubuntu安装宝塔面板MongoDB修改配置文件本地连接
服务器·mongodb·ubuntu
未兆3 天前
dbeaver连接mongodb 插入日期变成了字符串
数据库·mongodb
꧁༺朝花夕逝༻꧂3 天前
MongoDB
数据库·mongodb
碧海饮冰4 天前
MongoDB 与 Elasticsearch 使用场景区别及示例
数据库·mongodb·elasticsearch
_可乐无糖4 天前
mac安装mongoDB的正确姿势
mongodb·macos
曾续缘4 天前
docker安装mongoDB
mongodb·docker·容器