zoukankan      html  css  js  c++  java
  • MySQL全备及备份文件删除脚本

    1.数据库全备

    #!/bin/sh
    v_user="root"
    v_password="mysql"
    backup_date=`date +%Y%m%d%H%M`
    MysqlDir=/usr/local/mysql/bin
    BackupDir=/data/mysql
    Full_Backup=$BackupDir/Full_backup
    mkdir -p $Full_Backup/$backup_date
    echo '========='$(date +"%Y-%m-%d %H:%M:%S")'=========='"BEGIN">>$Full_Backup/$backup_date/full_backup.log
    $MysqlDir/mysqldump -u$v_user -p$v_password --single-transaction --flush-logs  --all-databases>$Full_Backup/$backup_date/full_backup.sql
    gzip $Full_Backup/$backup_date/full_backup.sql
    echo '=========='$(date +"%Y-%m-%d %H:%M:%S")'=========='"FINISH">>$Full_Backup/$backup_date/full_backup.log
     
    2.删除30天前备份文件
    echo "`date +'%Y-%m-%d %H:%M:%S'` remove full_backup_files 30 days ago"|tee -a /data/mysql/remove_backup_files.log && find /data/mysql/Full_backup -name "full_backup.*" -mtime +30 -type f| tee -a /data/mysql/remove_backup_files.log | xargs rm -f 2>&1
     
    3.定时任务设置
    #每天1点定时执行全库备份
    0 1 * * * /data/mysql/full_backup.sh
    #每天1点30分定时删除30天前备份文件
    30 1 * * * /data/mysql/remove_backup_files.sh
     
    参考链接:https://blog.csdn.net/songxixi/article/details/8787647?depth_1-utm_source=distribute.pc_relevant_right.none-task&utm_source=distribute.pc_relevant_right.none-task
  • 相关阅读:
    17多校6 HDU
    E. Present for Vitalik the Philatelist 反演+容斥
    HDU
    F. Cowmpany Cowmpensation dp+拉格朗日插值
    hdu6088 组合数+反演+拆系数fft
    任意模数fft
    Codeforces Round #258 (Div. 2)E
    bzoj3670: [Noi2014]动物园
    HDU
    IO-InputStreamReader
  • 原文地址:https://www.cnblogs.com/orcl-2018/p/12522435.html
Copyright © 2011-2022 走看看