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

相关推荐
weixin_462446238 小时前
解决MongoDB官网下载过慢问题
数据库·mongodb
ServBay1 天前
MongoDB 的文档模型与 CRUD 实战
数据库·后端·mongodb
Lisonseekpan2 天前
技术选型分析:MySQL、Redis、MongoDB、ElasticSearch与大数据怎么选?
大数据·redis·后端·mysql·mongodb·elasticsearch
哈库纳玛塔塔2 天前
MongoDB 数据库 ORM/ODM 新工具
java·数据库·spring boot·mongodb·orm
未秃头的程序猿2 天前
《Spring Boot MongoDB革命性升级!silky-mongodb-spring-boot-starter发布,开发效率暴增300%!》
后端·mongodb
玩具猴_wjh2 天前
MongoDB
数据库·mongodb
CN-Dust3 天前
MongoDB|Windows版安装教程(附资源)
数据库·windows·mongodb
自不量力的A同学3 天前
MongoDB 数据库 ORM/ODM 新工具
数据库·mongodb
半夏知半秋5 天前
MongoDB 与 Elasticsearch 数据同步方案整理
大数据·数据库·mongodb·elasticsearch·搜索引擎
IT布道5 天前
MongoDB性能调优之--关闭THP
数据库·mongodb