Oracle数据库定时备份并删除旧文件

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

2、创建Windows定时任务,每天0点定时备份bat批处理文件:

@echo off

schtasks /create /tn OA数据库定时备份(任务名称) /tr "cmd /c D:\ezoffice_backup_dzj.bat" /sc daily /st 00:00:00 /ru "system"

PAUSE

EXIT

你可能感兴趣的:(Oracle数据库定时备份并删除旧文件)