备份BinLog并压缩 全备份

Rem Backup Mysql Binlog

Rem Backup Yesterday and RAR

Rem Backup every day 00:01 begin backup yesterday and now binlog



@set curPath=%~dp0

@set SourcePath="\\110\ProgramData\MySQL\MySQL_Server_5.6\data\mysql-bin.*"

@set WinRARPath="C:\Program Files\WinRAR\Rar.exe"



@set BackupPath="%curPath%data"



@Rem Yestoday

@echo wscript.echo dateadd("d",-1,date)>GetOldDate.vbs

@for /f "tokens=1,2,3* delims=-/. " %%i in ('cscript /nologo GetOldDate.vbs') do (

   @set y=%%i

   @set m=%%j

   @set d=%%k

)

@if %m% LSS 10 set m=0%m%

@if %d% LSS 10 set d=0%d%

@set Yestoday=%m%-%d%-%y%

@set YestodayFolder=%y%-%m%-%d%

@del GetOldDate.vbs

@echo %Yestoday%



@rem make yestoday folder

@mkdir %BackupPath%\%YestodayFolder%\



xcopy %SourcePath% %BackupPath%\%YestodayFolder% /s /c /h /y /d:%Yestoday%

@rem -m  存储方式: 0存储、1最快、2快速、3标准、4较好、5最优

%WinRARPath% a %BackupPath%\%YestodayFolder%.rar %BackupPath%\%YestodayFolder%

@ping -n 10 127.0.0.1>nul

rmdir /s /q %BackupPath%\%YestodayFolder%

Mysqldump全备份

@Rem 检测是32位还是64位

@REM code from http://support.microsoft.com/kb/556009/en-us

@SET Bits=32

SET RegQry=HKLM\Hardware\Description\System\CentralProcessor\0

(REG.exe QUERY %RegQry%  | Find /i "x86")

If %ERRORLEVEL% == 0 (

    REM 32 Bit

    SET Bits=32

)ELSE (

    REM 64 Bit

    SET Bits=64

)

 

@REM 设定mysqldump文件

@SET curPath=%~dp0

@SET MysqlDump=%curPath%mysqldump_exe\mysqldump_%Bits%.exe



@REM 当前日期

@set CurrentDay=%date:~,4%%date:~5,2%%date:~8,2%



@Rem 设定备份目标目录

set Backup_Folder="%curPath%sql"



@Rem 设置数据库服务器IP及数据库信息

set Dump_IP="192.168.1.110"

set User_Name="root"

set Password="1234"

set Database="test"



%MysqlDump% -h %Dump_IP% -u%User_Name% -p%Password% %Database% --default-character-set=utf8 --single-transaction --compress --max_allowed_packet=10240000 --net_buffer_length=16384 >%Backup_Folder%\%CurrentDay%.sql

你可能感兴趣的:(binlog)