Mysql 冷备份批处理

@Rem Generate today date

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

@for /f %%a in ('cscript /nologo GetOldDate.vbs') do @set OldDate=%%a

@Rem echo %OldDate%

@del GetOldDate.vbs

@rem Replace/to-

@set Current_Date=%OldDate:/=-%



@Rem Generate 7 days ago

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

@for /f %%a in ('cscript /nologo GetOldDate.vbs') do @set OldDate=%%a

@Rem echo %OldDate%

@del GetOldDate.vbs

@rem Replace/to-

@set SevenDaysAgo_Date=%OldDate:/=-%



@Rem echo %Current_Date%;

@Rem echo %SevenDaysAgo_Date%;



@rem Delete local backup data and remote 7 days ago backup data

rd /s /Q "D:\ProgramData\MySQL\MySQL Server 5.6\backup\data"

rd /s /Q "\\110\KWM_Backup\%SevenDaysAgo_Date%"



@rem Stop Mysql Service

net stop mysql



@rem Copy data to local driver

D:

robocopy "D:\ProgramData\MySQL\MySQL Server 5.6\data" "D:\ProgramData\MySQL\MySQL Server 5.6\backup\data" /MIR /MT:50 /Log:"D:\ProgramData\MySQL\MySQL Server 5.6\robocopy_log_1.txt"



@rem Start Mysql Service

net start mysql



@rem Copy backup data to 110 server

robocopy "D:\ProgramData\MySQL\MySQL Server 5.6\backup\data" "\\110\KWM_Backup\%Current_Date%\data" /MIR /MT:50 /Log:"D:\ProgramData\MySQL\MySQL Server 5.6\robocopy_log_2.txt"

你可能感兴趣的:(mysql)