批处理根据星期自动备份到服务器的相应文件夹
直接上代码,
特点:
1根据系统日期,判断当前星期,自动备份到相应的文件夹mon、tue、wed……
2支持中文日期、英文日期
3覆盖前比较文件,如果文件相同则跳过(提高备份效率)
代码
@echo off
echo ### Backing up directory...
ECHO Y
set week=mon
date /t|find "一">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Mon">nul
if %errorlevel% equ 0 goto CCBAK
set week=tue
date /t|find "二">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Tue">nul
if %errorlevel% equ 0 goto CCBAK
set week=wed
date /t|find "三">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Wed">nul
if %errorlevel% equ 0 goto CCBAK
set week=thu
date /t|find "四">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Thu">nul
if %errorlevel% equ 0 goto CCBAK
set week=fri
date /t|find "五">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Fri">nul
if %errorlevel% equ 0 goto CCBAK
set week=sat
date /t|find "六">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Sat">nul
if %errorlevel% equ 0 goto CCBAK
echo Error!Application cannot get date from system.
@pause
goto CCExit
:CCBAK
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ###backing ACT ###
%backupcmd% "C:\EPRO\ACT\*.*" "\\10.13.5.54\d$\epro_bkup\act\%week%\act_server\"
%backupcmd% "C:\EPRO\FxACT\*.*" "\\10.13.5.54\d$\epro_bkup\act\%week%\act_client\"
echo ###ACT Complete###
echo ###backing EBS ###
%backupcmd% "C:\EPRO\EBS\*.*" "\\10.13.5.54\d$\epro_bkup\ebs\%week%\"
echo ### EBS Complete ###
echo Backup Complete!
@pause
:CCExit
echo ### Backing up directory...
ECHO Y
set week=mon
date /t|find "一">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Mon">nul
if %errorlevel% equ 0 goto CCBAK
set week=tue
date /t|find "二">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Tue">nul
if %errorlevel% equ 0 goto CCBAK
set week=wed
date /t|find "三">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Wed">nul
if %errorlevel% equ 0 goto CCBAK
set week=thu
date /t|find "四">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Thu">nul
if %errorlevel% equ 0 goto CCBAK
set week=fri
date /t|find "五">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Fri">nul
if %errorlevel% equ 0 goto CCBAK
set week=sat
date /t|find "六">nul
if %errorlevel% equ 0 goto CCBAK
date /t|find "Sat">nul
if %errorlevel% equ 0 goto CCBAK
echo Error!Application cannot get date from system.
@pause
goto CCExit
:CCBAK
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ###backing ACT ###
%backupcmd% "C:\EPRO\ACT\*.*" "\\10.13.5.54\d$\epro_bkup\act\%week%\act_server\"
%backupcmd% "C:\EPRO\FxACT\*.*" "\\10.13.5.54\d$\epro_bkup\act\%week%\act_client\"
echo ###ACT Complete###
echo ###backing EBS ###
%backupcmd% "C:\EPRO\EBS\*.*" "\\10.13.5.54\d$\epro_bkup\ebs\%week%\"
echo ### EBS Complete ###
echo Backup Complete!
@pause
:CCExit