批处理根据星期自动备份到服务器的相应文件夹

直接上代码,

特点:

  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 ////////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


posted on 2011-02-15 16:23  咖啡色  阅读(559)  评论(0编辑  收藏  举报