下面是两个定时远程备份服务器数据的批处理代码:请高手将此两个批处理合并,并改为可静默执行的VBS文件,谢过!
1、 复制实报服务器Oracle数据库备份文件到客户端批处理脚本- CLS
- @echo off
- echo ******************************************************************
- echo * 复制实报服务器Oracle数据库备份文件到客户端批处理脚本 *
- echo * By Zhangjian E-mail: *
- echo * %date:~0,10% %time:~0,8% *
- echo ******************************************************************
-
- @echo off
- mode con cols=80 lines=20
- title 远程复制程序
- color 04
- cls
-
- REM 设置备份目录
- set BACKUP_DIR=D:\BACKUP\SBSX_BACKUP
- set LOGTXT=LOG.RZ
-
- REM 取当前系统时间,可能因操作系统不同而取值不一样
- set CURDATE=%date:~0,4%%date:~5,2%%date:~8,2%
- set CURTIME=%time:~0,2%
-
- REM 小时数如果小于10,则在前面补0
- if "%CURTIME%"==" 0" set CURTIME=00
- if "%CURTIME%"==" 1" set CURTIME=01
- if "%CURTIME%"==" 2" set CURTIME=02
- if "%CURTIME%"==" 3" set CURTIME=03
- if "%CURTIME%"==" 4" set CURTIME=04
- if "%CURTIME%"==" 5" set CURTIME=05
- if "%CURTIME%"==" 6" set CURTIME=06
- if "%CURTIME%"==" 7" set CURTIME=07
- if "%CURTIME%"==" 8" set CURTIME=08
- if "%CURTIME%"==" 9" set CURTIME=09
- set FILTIME=%CURTIME%%time:~3,2%%time:~6,2%
- set LOGTIME=%CURTIME%:%time:~3,2%:%time:~6,2%
-
- REM 创建备份目录
- if not exist %BACKUP_DIR% md %BACKUP_DIR%
-
- REM 设备份目录为当前目录
- pushd %BACKUP_DIR%
- set CURDIR=%BACKUP_DIR%
-
- REM 删除超过10天的备份
- for /f "skip=10" %%i in ('dir/b/o-d *.DMP') do del %%i&&echo.%date:~0,10% %LOGTIME% 从%BACKUP_DIR%删除%%i>>%CURDIR%\%LOGTXT%
- for /f "skip=10" %%i in ('dir/b/o-d *.LOG') do del %%i&&echo.%date:~0,10% %LOGTIME% 从%BACKUP_DIR%删除%%i>>%CURDIR%\%LOGTXT%&&echo.------------------------------------------------------------------>>%CURDIR%\%LOGTXT%
-
- REM 映射服务器备份目录为本地S盘
- net use T: \\192.168.1.13\SBSX_BAK server2008 /user:administrator
- pushd t:\
-
- REM 复制最后一次备份文件到当前目录
- for /f %%i in ('dir/od/b *.DMP') do set dmpfile=%%i
- for /f %%i in ('dir/od/b *.LOG') do set logfile=%%i
- Xcopy /-y %dmpfile% %BACKUP_DIR%&&echo.%date:~0,10% %LOGTIME% 复制%dmpfile%到%BACKUP_DIR%>>%CURDIR%\%LOGTXT%
- Xcopy /-y %logfile% %BACKUP_DIR%&&echo.%date:~0,10% %LOGTIME% 复制%logfile%到%BACKUP_DIR%>>%CURDIR%\%LOGTXT%&&echo.------------------------------------------------------------------>>%CURDIR%\%LOGTXT%
-
- REM 断开映射
- net use T: /del /y
- exit
复制代码 2、复制服务器SQLServer数据库备份文件到客户端批处理脚本- CLS
- @echo off
- echo ******************************************************************
- echo * 复制服务器SQLServer数据库备份文件到客户端批处理脚本 *
- echo * By Zhangjian E-mail: *
- echo * %date:~0,10% %time:~0,8% *
- echo ******************************************************************
-
- @echo on
- mode con cols=80 lines=20
- title 远程复制程序
- color 04
- cls
-
- REM 设置备份目录
- set BACKUP_DIR=D:\BACKUP\GXSV4_BACKUP
- set LOGTXT=LOG.RZ
-
- REM 取当前系统时间,可能因操作系统不同而取值不一样
- set CURDATE=%date:~0,4%%date:~5,2%%date:~8,2%
- set CURTIME=%time:~0,2%
-
- REM 小时数如果小于10,则在前面补0
- if "%CURTIME%"==" 0" set CURTIME=00
- if "%CURTIME%"==" 1" set CURTIME=01
- if "%CURTIME%"==" 2" set CURTIME=02
- if "%CURTIME%"==" 3" set CURTIME=03
- if "%CURTIME%"==" 4" set CURTIME=04
- if "%CURTIME%"==" 5" set CURTIME=05
- if "%CURTIME%"==" 6" set CURTIME=06
- if "%CURTIME%"==" 7" set CURTIME=07
- if "%CURTIME%"==" 8" set CURTIME=08
- if "%CURTIME%"==" 9" set CURTIME=09
- set FILTIME=%CURTIME%%time:~3,2%%time:~6,2%
- set LOGTIME=%CURTIME%:%time:~3,2%:%time:~6,2%
-
- REM 创建备份目录
- if not exist %BACKUP_DIR% md %BACKUP_DIR%
-
- REM 设备份目录为当前目录
- pushd %BACKUP_DIR%
- set CURDIR=%BACKUP_DIR%
-
- REM 删除超过10天的备份
- for /f "skip=10" %%i in ('dir/b/o-d *.bak') do del %%i&&echo.%date:~0,10% %LOGTIME% 从%BACKUP_DIR%删除%%i>>%CURDIR%\%LOGTXT%
- for /f "skip=10" %%i in ('dir/b/o-d *.txt') do del %%i&&echo.%date:~0,10% %LOGTIME% 从%BACKUP_DIR%删除%%i>>%CURDIR%\%LOGTXT%&&echo.------------------------------------------------------------------>>%CURDIR%\%LOGTXT%
-
- REM for /f "skip=10 tokens=*" %%i in ('dir/b/o-d *.BAK') do rd "%%i"
- REM for /f "skip=10 tokens=*" %%i in ('dir/b/o-d *.TXT') do rd "%%i"
-
-
- REM 映射服务器备份目录为本地S盘
- net use U: \\192.168.1.13\GXS4_BAK server2008 /user:administrator
- pushd U:\
-
- REM 复制最后一次备份文件到当前目录
- for /f %%i in ('dir/od/b *.BAK') do set dmpfile=%%i
- for /f %%i in ('dir/od/b *.TXT') do set logfile=%%i
- Xcopy /-y %dmpfile% %BACKUP_DIR%&&echo.%date:~0,10% %LOGTIME% 复制%dmpfile%到%BACKUP_DIR%>>%CURDIR%\%LOGTXT%
- Xcopy /-y %logfile% %BACKUP_DIR%&&echo.%date:~0,10% %LOGTIME% 复制%logfile%到%BACKUP_DIR%>>%CURDIR%\%LOGTXT%&&echo.------------------------------------------------------------------>>%CURDIR%\%LOGTXT%
-
- REM 断开映射
- net use U: /del /y
- exit
复制代码
|