@echo off echo ================================================ echo Windows环境下Oracle数据库的自动备份脚本 echo 1. 使用当前日期命名备份文件 echo 2. 自动删除7天前的备份 echo ================================================ ::以“YYYYMMDD”格式取出当前时间 set BACKUPDATE=%date:~0,4%%date:~5,2%%date:~8,2% ::设置用户名、密码和要备份的数据库 set USER=xxxset 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
原文地址:https://blog.csdn.net/iw1210/article/details/39312783
原文地址:https://www.cnblogs.com/nethrd/p/9802946.html
时间: 2024-10-05 00:31:08