Windows下多Oracle实例,根据用户自动备份
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| @echo off echo ================================================ echo Windows环境下Oracle数据库的自动备份脚本 echo 1. 使用当前日期命名备份文件。 echo 2. 自动删除30天前的备份。 echo ================================================ ::以“YYYYMMDD”格式取出当前时间。 set BACKUPDATE=%date:~0,4%%date:~5,2%%date:~8,2% set DATADIR=E:\database_backup\%BACKUPDATE% echo 本次备份目录是%DATADIR% echo ================================================ echo 开始备份数据库 for %%u in (AIR_FORECAST,ALK,AIR_FZ,TSUBJECT,TMAIN,TCODE,AIR_YBYJ,AIR_FXPT,INVENTORY,TENV,NEWMBGL) do expdp userid='sys/密码@实例 as sysdba' schemas=%%u directory=DATA_PUMP_DIR dumpfile=%%u.dmp echo 移动文件到数据库备份目录 if not exist "E:\database_backup\%BACKUPDATE%" mkdir E:\database_backup\%BACKUPDATE% MOVE /Y E:\app\Administrator\admin\SX21\dpdump\* E:\database_backup\%BACKUPDATE% ::删除30天前的备份 forfiles /p E:\database_backup\ /m 201* /d -30 /c "cmd /c if @isdir==TRUE (rmdir /q /s @path) else (del /f @path)" exit
|
参考:
http://www.cnblogs.com/peterpanzsy/p/3442784.html
http://blog.csdn.net/smasegain/article/details/46759267