6000609a394e41346.png_fo742.png
先做免密登录
样式有问题 变量取值不见了

#!/bin/bash
LOCAL_DIR=/data/bakup/mysql
REMOTE_DIR=/data/bakup/mysql
RIP="123.124.125.126"
RPORT=22
REXE="ssh -p RPORTRIP"

for file in `REXE lsREMOTE_DIR`;do
    if [ -f LOCAL_DIR/file ];then
        md5_local=`md5sum  LOCAL_DIR/file  |awk '{print 1}'`
        md5_remote=`REXE md5sum  REMOTE_DIR/file  |awk '{print 1}'`
        if [md5_local == md5_remote ];then
            echo "file on local already,skip"
        else
            echo "file broken,clean..."
            rm -rfLOCAL_DIR/file
        fi
    else
        echo "Starting bakfile"
        scp -P RPORTRIP:REMOTE_DIR/file LOCAL_DIR
        if [ "0" -eq? ];then
            echo "Delete  file"REXE rm -rf REMOTE_DIR/file
        fi
    fi
done

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code