Windows:Oracle 11g 备份脚本

时间:2023-03-08 17:20:27
Windows:Oracle 11g 备份脚本
@echo off
echo ================================================
echo Windows环境下Oracle数据库的自动备份脚本
echo . 使用当前日期命名备份文件
echo . 自动删除7天前的备份
echo ================================================
::以“YYYYMMDD”格式取出当前时间
set BACKUPDATE=%date:~,%%date:~,%%date:~,%
::设置用户名、密码和要备份的数据库
set USER=xxxset PASSWORD=xxx
set DATABASE=xxx
::创建备份目录
if not exist "E:\4-Backup\data" mkdir E:\-Backup\data
if not exist "E:\4-Backup\log" mkdir E:\-Backup\log
set DATADIR=E:\-Backup\data
set LOGDIR=E:\-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

原文地址:https://blog.csdn.net/iw1210/article/details/39312783