1. 程式人生 > >Rsync 增量同步指令碼(容災備份伺服器)

Rsync 增量同步指令碼(容災備份伺服器)

#/bin/bash

author : Jerry

update : 2018-11-30

FrtIP=192.168.25.
Sip=(72 45 41 70 249 43 114)
Names=(RY72 WXJ45 LJ41 WHL70 YLJ249 WHR43 PJH114)
logs=/opt/Tools/rzbackup.log
decide() {
if [ $1 == 0 ];then
echo -e "\033[32m $2 Backup Done \033[0m" >>$logs
elif [ $1 == 23 ];then
echo -e "\033[33m $2 Backup Warning \033[0m" >>$logs
else
echo -e "\033[31m $2 Backup Failure \033[0m">>$logs
fi
echo " ">>$logs
}

for Num in seq 0 6
do
echo "##date +%D' '%T>>>>>>## " >>$logs
echo "##${Names[$Num]} Server DB backup ...##" >>$logs
sudo /usr/bin/rsync --port=873 -vazrtopg --progress [email protected]$FrtIP${Sip[$Num]}::db/* /data/idcdata/${Names[$Num]} --password-file=/etc/rsyncd.secrets &>>$logs
values=echo $?


decide $values $FrtIP${Sip[$Num]}
done
echo -e "\033[36m >>>>>>>>>>ALL Begin>>>>>>date +%D' '%T>>>>>>>>>>>>> \033[0m" >>$logs

Rsync 增量同步指令碼(容災備份伺服器)