• 自动备份数据库文件脚本


    vim usr/bin/zdbf.sh

    #!/bin/sh

    # Database info
    DB_USER="root"
    DB_PASS="password"
    DB_HOST="ip"

    DB_USER1="root"
    DB_PASS1="password"
    DB_HOST1="ip2"


    # Database array
    DB_NAME=("ag_file" "ag_sd" "ag_storage" "customer_service" "scdata")
    # Others vars
    BIN_DIR="/usr/local/mysql/bin" #the mysql bin path
    BCK_DIR="/home/mysql-backups" #the backup file directory
    DATE=`date +%F`
    # create file


    if [ ! -d "$BCK_DIR/$DATE" ]; then
    echo "chuangjianwenjianji"
    mkdir $BCK_DIR/$DATE
    else
    echo "yicunzai"
    fi


    #mkdir $BCK_DIR/$DATE
    # TODO
    # /usr/bin/mysqldump --opt -ubatsing -pbatsingpw -hlocalhost timepusher > /mnt/mysqlBackup/db_`date +%F`.sql
    $BIN_DIR/mysqldump -u$DB_USER -p$DB_PASS -h$DB_HOST scdata> $BCK_DIR/$DATE/scdata.sql
    $BIN_DIR/mysqldump -u$DB_USER1 -p$DB_PASS1 -h$DB_HOST1 ag_file> $BCK_DIR/$DATE/ag_file.sql
    $BIN_DIR/mysqldump -u$DB_USER1 -p$DB_PASS1 -h$DB_HOST1 ag_sd> $BCK_DIR/$DATE/ag_sd.sql
    $BIN_DIR/mysqldump -u$DB_USER1 -p$DB_PASS1 -h$DB_HOST1 ag_storage> $BCK_DIR/$DATE/ag_storage.sql
    $BIN_DIR/mysqldump -u$DB_USER1 -p$DB_PASS1 -h$DB_HOST1 customer_service> $BCK_DIR/$DATE/customer_service.sql

    加入Linux定时执行

    crontab -e

    54 14 * * * /usr/bin/zdbf.sh

  • 相关阅读:
    codevs 1069关押罪犯
    codevs 1497取余运算
    codevs 3324 新斯诺克
    codevs 3286 火柴排队
    继续畅通工程
    还是畅通工程
    畅通工程(并查集找根节点)
    Eddy's picture(最小生成树)
    Constructing Roads(最小生成树)
    Codeforces Round #383 (Div. 2)C. Arpa's loud Owf and Mehrdad's evil plan
  • 原文地址:https://www.cnblogs.com/cw828/p/10626871.html
Copyright © 2020-2023  润新知