#!/bin/bash

function rsync_snapshot_to_backup_server(){
    rsync -avzP --delete ${LOCAL_BACKUP_DIR} edoc2_backup@${REMOTE_BACKUP_SERVER}::es/ --password-file=/etc/rsync_client.password &>/dev/null
    if [ $? -eq 0 ];then
        echo "$(date +%F%T) ES rsync backup success." >> /tmp/esrsync.log
    else
        echo "$(date +%F%T) ES rsync backup failed." >> /tmp/esrsync.log
    fi
}

# 容器映射到 宿主机的 备份目录
# v6.7.1.11 之前默认的快照文件目录
LOCAL_BACKUP_DIR=/home/edoc2/macrowing/edoc2v5/data/es/backup
# v6.7.1.11 之后默认的快照文件目录
# LOCAL_BACKUP_DIR=/home/esbackup
# 异机备份ip，rsync服务端
REMOTE_BACKUP_SERVER=192.168.20.200

rsync_snapshot_to_backup_server

