MySQL database InnoDB storage Engine backup script

Source: Internet
Author: User

#!/bin/bash# author: movekj# descript: backup mysql. full backup in  sunday,incremental backup in other day. (for innodb store engine) # version: 0.0.1 ### define variablespath= "/ usr/java/latest/bin:/usr/lib64/qt-3.3/bin:/usr/java/latest/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/ Sbin:/usr/bin:/root/bin "backupuser=backuperbackuppassword= ... 1workpath=/home/backuplogpath=/home/backup/log/fullbackuppath=/home/backup/full/increbackuppath=/home/backup/ incre/dayofweek= ' date +%u ' weekofyear= ' date +%w ' date= ' date +%f ' ### define  Functioncreatebackuppath ()  {if [ ! -d $1$2 ]thenmkdir -p $1$2  && echo -e  "' Date '  \033[31m$1$2 is create successful!\033[0m" #> >  $LogPath $weekofyear/backup_$date.log fi}deleteoldbackup ()  {backupnum= ' ls $1 |  wc -L ' if [  $BackupNum  -gt 3 ]thenoldbackupnum=$[$BackupNum -3]oldbackup= ' ls -t  $1 | tail -$OldBackupNum '     ### find old backupfor i  in  $OldBackupdosudo  rm -rf $1$I && echo  "' Date '  $1$i  is deleted! "   >> ${logpath}backup_delete.logdonefi}delete ()  {         DeleteOldBackup  $FullBackupPath     ### DELETE OLD  full backup        deleteoldbackup  $IncreBackupPath     ### DELETE OLD INCREMENTAL BACKUP          #DeleteOldBackup   $LogPath           ###  delete old log file }createbackuppath  $LogPath   $WeekOfYear        ### create backup log pathcreatebackuppath  $FullBackupPath   $WeekOfYear     ## CREATE FULL BACKUP PATHCreateBackupPath  $IncreBackupPath  $ weekofyear    ### create incremental backup path### start  progressif [  $DayOfWeek  -eq 1 ]theninnobackupex --user= $BackupUser  -- password= $BackupPassword   $FullBackupPath $weekofyear 2>>  $LogPath $weekofyear/full_backup_$ date.log >>  $LogPath $weekofyear/full_backup_$date.logif [ $? -eq 0 ]         thenDelete         fielif [  $DayOfWeek  -eq 2 ]thennewestfullbackup= ' ls -t  $FullBackupPath $ Weekofyear | head -1 '     ### FIND NEWEST FULL  backupinnobackupex --user= $BackupUser &Nbsp;--password= $BackupPassword  --incremental --incremental-basedir= $FullBackupPath $weekofyear/$ newestfullbackup  $IncreBackupPath $weekofyear 2>>  $LogPath $weekofyear/incre_backup_$ date.log >>  $LogPath $weekofyear/incre_backup_$date.logif [ $? -eq 0 ] then deletefielsenewestincrebackup= ' ls -t  $IncreBackupPath $weekofyear | head -1 '     ### find newest incremental backupinnobackupex --user=$ backupuser --password= $BackupPassword  --incremental --incremental-basedir= $IncreBackupPath $ weekofyear/$NewestIncreBackup   $IncreBackupPath $weekofyear 2>>  $LogPath $weekofyear/incre_ backup_$date.log >>  $LogPath $weekofyear/incre_backup_$date.logif [ $? -eq  0 ]    thendelete    fifi

This article is from "Chalet Technology" blog, please make sure to keep this source http://starli.blog.51cto.com/8813574/1707393

MySQL database InnoDB storage Engine backup script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.