sybase資料庫自動備份
阿新 • • 發佈:2019-01-02
指令碼名稱:dump.sh
呼叫方式 :dump.sh 資料庫名稱
指令碼內容:
#!/bin/bash
DUMP_PATH=/home/sybase/DUMP_NAME=$1
DUMP_SUFFIX=.dump
DUMP_FILE=${DUMP_PATH}${DUMP_NAME}${DUMP_SUFFIX}
echo ${DUMP_FILE}
INDEX=0
while [ -f ${DUMP_FILE} ]//備份名稱字尾遞增,比如master0.dump master1.dump master2.dump
do
DUMP_FILE=${DUMP_PATH}${DUMP_NAME}${INDEX}${DUMP_SUFFIX}
echo "DUMP to "${DUMP_FILE}
let INDEX+=1
done
echo ${DUMP_FILE}
VALUE=$(su - sybase -c "isql -Uuser -Ppasswd <<@@@
dump database ${DUMP_NAME} to \"${DUMP_FILE}\"
go
@@@")
if [ -z "${VALUE}" ];then
echo "The result is 0"
else
echo "The result is not 0"
fi