??????MySQL?????????
???????????? ???????[ 2016/12/14 10:07:46 ] ????????????? MySQL
????#!/bin/bash
????##autor by huwj 20161019
????MysqlDump='/usr/bin/mysqldump'
????hostPort='localhost'
????database='dbName'
????dbPath='/data/mysqlBak/dbName'
????uName='dbName'
????uPass='dbPasswd'
????Date=`date '+%Y%m%d%H%M'`
????backPath='/data/mysqlBak/mysqlBack'
????runLog="$backPath/log/run.log"
????RM='/bin/rm'
????MV='/bin/mv'
????MKDIR='/bin/mkdir'
????Find='/bin/find'
????Tar='/bin/tar'
????echo 'date=='$Date
????#???15???????????? ?????????????????????????????м??????????????????????????????????
????delBackFile(){
????cd $backPath
????$Find -mtime +15 |xargs rm -rf
????}
????#delBackFile
????#?????б??????
????# the directory for story the newest backupss
????test ! -d "$backPath/backup.0/" && $MKDIR -p "$backPath/backup.0/"
????backUpMongo(){
????if [ ! -d "$dbPath/$database" ]; then
????echo "$Date starting to backup ..." >> $runLog
????$MysqlDump -h $hostPort -u $uName -p$uPass $database > $dbPath/$database.sql
????cd $dbPath
????echo "$Date starting to tar backfile..." >> $runLog
????$Tar -zcvf $backPath/backup.0/$database.$Date.tar.gz $database.sql
????if [ -f "$backPath/backup.0/$database.$Date.tar.gz" ];then
????$RM -rf $dbPath/$database.sql
????echo "$Date backSuccess ??starting to mv backfile..." >> $runLog
????# delete the oldest backup
????test -d "$backPath/backup.15/" && $RM -rf "$backPath/backup.15"
????# rotate backup directory
????echo "$Date mv success ??starting to mv oldFile ....." >> $runLog
????for int in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
????do
????if ( test -d "$backPath"/backup."$int" )
????then
????next_int=`expr $int + 1`
????$MV "$backPath"/backup."$int" "$backPath"/backup."$next_int"
????fi
????done
????fi
????else
????echo "$Date rm backfile ...." >> $runLog
????$RM -rf $dbPath/$database.sql
????fi
????}
????backUpMongo
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11