zoukankan      html  css  js  c++  java
  • es备份和恢复

    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
  • 相关阅读:
    【JavaEE】之MyBatis开发DAO
    【JavaEE】之MyBatis与原生JDBC、Hibernate访问数据库的比较
    【JavaEE】之MyBatis插入数据后获取自增主键
    【JavaEE】之MyBatis的ParameterType的使用
    【Android
    【Android
    【设计模式】
    【设计模式
    架构师十项技能
    tcp 出现rst情况整理
  • 原文地址:https://www.cnblogs.com/hxlasky/p/14697654.html
Copyright © 2011-2022 走看看