我想问一下这个问题我想每10分钟备份一次数据库表并与现有的数据库表进行比较。 这里
@echo off
set tbluser=user_tbl
set tblticket=ticket_tbl
::REM set Date
set datetoday=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do (
set hh=%%i
set mm=%%j
)
set datentime = %datetoday%%hh%%mm%
::set path
set dBackup="D:\dbBackup\dailybackup"
set wBackup="D:\dbBackup\weeklybackup"
set zip="C:\Program Files\7-Zip\7z.exe"
FC /B %wBackup%\%tblticket%.sql %dBackup%\%tblticket%_%datentime%.sql
IF %wBackup%\%tblticket%.sql EQU %dBackup%\%tblticket%_%datentime%.sql (DEL %dBackup%\%tblticket%.sql) ELSE (%zip% a -tgzip %dBackup%\%tblticket%_%datentime%.sql.gz %dBackup%\%tblticket%_%datentime%.sql
del %dBackup%\%tblticket%_%datentime%.sql)
@pause
答案 0 :(得分:0)
1 - 我不知道如何备份您的数据库。没有信息。
2 - 您从%date%
环境变量获取当前日期。使用%time%
变量
3 - 要测试两个文件的相等性,在使用FC进行比较后,检查errorlevel以了解命令是否失败
FC /b file1 file2 > nul
if errorlevel 1 (
rem files are different
) else (
rem files are identical
)