首页 > 其他 > 详细

es备份和恢复

时间:2021-04-24 20:45:32      阅读:21      评论:0      收藏:0      [点我收藏+]

 

1.备份

root@elasticsearch-010007081120 ~]# more /home/elasticsearch/script/es_backup.sh
#!/bin/sh
now_date=`date "+%Y%m%d"`
delete_date=`date +%Y%m%d -d "1 days ago"` 


##删除之前的备份
curl -u elastic:Tg5jWUL8ri -H "Content-Type: application/json" -XDELETE "http://10.7.81.120:19200/_snapshot/esbackup/snapshot_$delete_d
ate"

##创建备份仓库目录
curl -u elastic:Tg5jWUL8ri -H "Content-Type: application/json" -XPUT http://10.7.81.120:19200/_snapshot/esbackup -d‘{
    "type": "fs", 
    "settings": {
        "location": "/home/middle/esbak"
    }
}
##备份
curl -u elastic:Tg5jWUL8ri -H "Content-Type: application/json" -XPUT http://10.7.81.120:19200/_snapshot/esbackup/snapshot_$now_date

[root@elasticsearch-010007081120 ~]# 
[root@elasticsearch-010007081120 ~]# more /home/elasticsearch/script/es_backup_tar.sh
#!/bin/bash
now_date=`date "+%Y%m%d"`
delete_date=`date +%Y%m%d -d "2 days ago"` 

tar_file=/home/middle/esbak_tar/esbak_${now_date}.tar.gz
cd /home/middle

tar -czvf ${tar_file} ./esbak

##删除本地备份文件
delete_tar_file=/home/middle/esbak_tar/esbak_${delete_date}.tar.gz

##删除本地文件
if [ -f "${delete_tar_file}" ];then
  rm ${delete_tar_file}
fi

 

es备份和恢复

原文:https://www.cnblogs.com/hxlasky/p/14697654.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!