1、创建一个expdp导出bat批处理任务,自动删除30天之前备份文件:
@echo off
rem set backupfile=f_database_%date:~0,4%-%date:~5,2%-%date:~8,2%.dmp
rem set logfile=f_database_%date:~0,4%-%date:~5,2%-%date:~8,2%.log
rem delete 30 days files
forfiles /p "D:\exp" /d -30 /c "cmd /c echo deleting @file ... && del /f @path"
rem backup schemas
set backupfile=OA_%date:~0,4%-%date:~5,2%-%date:~8,2%.dmp
set logfile=OA_%date:~0,4%-%date:~5,2%-%date:~8,2%.log
expdp ezoffice/13572468 directory=expdir dumpfile=%backupfile% logfile=%logfile% schemas=ezoffice parallel=4
简化版:
forfiles /p "D:\backup" /s /m *.dmp /d -10 /c "cmd /c del @path"
forfiles /p "D:\backup" /s /m *.log /d -10 /c "cmd /c del @path"
set mydate=%date:~0,4%%date:~5,2%%date:~8,2%
expdp ezoffice/13572468 directory=backup dumpfile=%mydate%.dmp logfile=%mydate%.log schemas=ezoffice parallel=4
2、创建Windows定时任务,每天0点定时备份bat批处理文件:
schtasks /create /tn OA数据库定时备份(任务名称) /tr "cmd /c D:\ezoffice_backup_dzj.bat" /sc daily /st 00:00:00 /ru "system"
PAUSE
EXIT