Windows:Oracle 11g 备份脚本
时间:2021-07-01 10:21:17
帮助过:15人阅读
================================================
echo Windows环境下Oracle数据库的自动备份脚本
echo 1. 使用当前日期命名备份文件
echo 2. 自动删除7天前的备份
echo ================================================
::以“YYYYMMDD”格式取出当前时间
set BACKUPDATE=%date:~
0,
4%%date:~
5,
2%%date:~
8,
2%
::设置用户名、密码和要备份的数据库
set USER=xxx
set PASSWORD=
xxx
set DATABASE=
xxx
::创建备份目录
if not exist
"E:\4-Backup\data" mkdir E:\
4-
Backup\data
if not exist
"E:\4-Backup\log" mkdir E:\
4-
Backup\log
set DATADIR=E:\
4-
Backup\data
set LOGDIR=E:\
4-
Backup\log
exp %USER%/%PASSWORD%@%DATABASE% file=%DATADIR%\data_%BACKUPDATE%.dmp log=%LOGDIR%\log_%BACKUPDATE%
.log
::删除7天前的备份
forfiles /p
"%DATADIR%" /s /m *.* /d -7 /c
"cmd /c del @path"
forfiles /p
"%LOGDIR%" /s /m *.* /d -7 /c
"cmd /c del @path"
pause
exit