数据库备份之冷备

#! /bin/bash
DB_HOST="127.0.0.1"
DB_NANE="testdatabase"
DB_USER="root"
DB_PASS=""
DATE=`date +%Y%m%d%h%m%s`
MYSQL_PATH=/root/
back_up(){
    BAKUP_FILE=${MYSQL_PATH}${DB_NAME}${DATE}.sql
    SQL_OPT="-u${DB_USER} -p${DB_PASS} -h${DB_HOST} ${DB_NAME}"
    mysqldump ${SQL_OPT} > ${BAKUP_FILE}
    if [ $? -eq 0 ];then
        echo 'ok';
    else
        echo 'error';
    fi
}
back_up;
    原文作者:蒙奇D颖
    原文地址: https://segmentfault.com/a/1190000018552237
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞