zoukankan      html  css  js  c++  java
  • mysql全备、增量备份脚本

     1.mysql全量备份及定时删除备份文件脚本
    #!/bin/bash
    v_user="root"
    v_password="mysql"
    backup_date=`date +%Y%m%d%H%M`
    mysqldir=/usr/local/mysql
    full_backup=/mysql/data/full_backup
    mkdir -p $full_backup/$backup_date
    $mysqldir/bin/mysqldump -u$v_user -p$v_password --single-transaction --master-data=2 -A -R -E --triggers --flush-logs>$full_backup/$backup_date/full_backup.sql
    gzip $full_backup/$backup_date/full_backup.sql
    find /mysql/data/full_backup -name "full_backup.*" -mtime +30 -type f | xargs rm -f
    
     
    2.mysql增量备份及定时删除增量备份文件脚本
    #!/bin/bash
    v_user="root"
    v_password="mysql"
    mysqldir=/usr/local/mysql
    incre_backup=/mysql/data/incre_backup
    mkdir -p $incre_backup
    $mysqldir/bin/mysqladmin -u$v_user -p$v_password flush-logs
    find /mysql/binlog -name "mysql-bin.*" -mtime -1 -type f  | xargs -i  cp {} $incre_backup
    find /mysql/data/incre_backup -name "mysql-bin.*" -mtime +30 -type f | xargs rm -rf
    
     
    3.mysql开启binlog
     查看是否开启binlog:
    mysql> show variables like 'log_bin';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | log_bin       | ON    |
    +---------------+-------+
     
    value为on,则说明已经开启binlog
    value为off,则说明未开启binlog
     
    如何开启binlog?
    修改MySQL参数文件my.cnf
    vi my.cnf
    log_bin=/data/3306/binlog/mysql‐bin
     
    重启MySQL
    show variables like 'log_bin';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | log_bin       | ON    |
    +---------------+-------+
    

      

     
     
  • 相关阅读:
    JS弹出层可拖拽
    DWZ搭建页面快速入门笔记
    JQuery 选择器总结
    最新身份证验证
    centos7磁盘扩容
    vue中使用vueamap(高德地图)
    后台数据格式有问题,更改数据格式
    《JavaScript高级程序设计(第3版)》问题收集
    slice()、substr()、substring()的结果
    【SQL】统计数据过程中利用Union去重
  • 原文地址:https://www.cnblogs.com/orcl-2018/p/12613343.html
Copyright © 2011-2022 走看看