Oracle automatically backs up and deletes the previous backup file for batch processing. I found some information from the Internet, sorted out oracle's automatic backup batch processing, and saved the following code. bat can be used together with windows scheduled tasks to automatically back up and compress the database, and delete the backup file seven days ago (modify the delDays parameter ). In windows 2003/2008, The forfiles tool is used for auxiliary deletion. Hope to be useful to everyone! Www.2cto.com Java code @ echo ------ ORACLE automatic backup starts... zhang Junming @ 2012 ----------- REM ================================== ================================= REM Backup Server SZYY System Data REM ================ ========================================================== ===@ echo off set BACKUP_DIR = e: \ DATABACKUP set BACKUP_WAREHOUSE = e: \ DATABACKUP \ DATABACKUP_LOG_DMP set ORACLE_USERNAME = zjm set ORACLE_PASSWORD = zjm123 set ORACLE_DB = orcl set IP = 192.168.5. 100 set RAR_CMD = "C: \ Program Files \ WinRAR \ WinRAR.exe "set delDays = 7 if not exist" DATABACKUP "md DATABACKUP if not exist" database up \ DATABACKUP_LOG_DMP \ "md DATABACKUP \ DATABACKUP_LOG_DMP \ for/f" tokens = 1, 2 "% a in ('date/t ') do set TODAY = % a REM if the file name takes hours and minutes, use the following first line of the statement REM set BACK_NAME = % ORACLE_DB % _ % ORACLE_USERNAME % _ % TODAY % (% time :~ 0, 2% hour % time :~ 3,2% min % time :~ 6, 2% seconds) REM set BACK_NAME = % ORACLE_DB % _ % ORACLE_USERNAME % _ % TODAY % REM set BACK_NAME = % ORACLE_DB % _ % TODAY % _ % time :~ 0, 2% hour % time :~ 3,2% min % time :~ 6, 2% second set BACK_NAME = % ORACLE_DB % _ % TODAY % set BACK_FULL_NAME = % BACKUP_DIR % \ % BACK_NAME % REM record the operation in the batch log % BACK_FULL_NAME % _ bat. log echo = ==>> % BACK_FULL_NAME % _ bat. log echo backup starts...> % BACK_FULL_NAME % _ bat. log echo Start time: % DATE % time %> % BACK_FULL_NAME % _ bat. log REM calls exp tool rem % ORACLE_USERNAME %/% ORACLE_PASSWORD % @ % IP %/% ORACLE_DB % grants = Y exp % ORACLE_USERNAME % /% ORACLE_PASSWORD % @ % IP %/% ORACLE_DB % grants = Y file = "% BACK_FULL_NAME %. dmp "rem log =" % BACK_FULL_NAME % _ exp. log "if not exist % BACKUP_WAREHOUSE % \ DMP md % BACKUP_WAREHOUSE % \ DMP echo compression and delete the original dmp file...> % BACK_FULL_NAME % _ bat. the current time of log echo is: % DATE % time %> % BACK_FULL_NAME % _ bat. log % RAR_CMD % a-df "%back_full_name1__dmp.rar" "% BACK_FULL_NAME %. dmp "echo rar compression ==> %back_full_name1__dmp.rar >>%back_full_name % _ ba T. log REM "% BACK_FULL_NAME % exp. log" echo compression and delete the original dmp file! >>% BACK_FULL_NAME % _ bat. the current time of log echo is: % DATE % time %> % BACK_FULL_NAME % _ bat. log echo starts to move the compressed backup file...> % BACK_FULL_NAME % _ bat. the current time of log echo is: % DATE % time %> % BACK_FULL_NAME % _ bat. log move % BACKUP_DIR % \*. rar % BACKUP_WAREHOUSE % \ DMP \ echo current time: % DATE % time % >>% BACK_FULL_NAME % _ bat. log REM net send % userdomain % "logical database backup completed at: % DATE % time %! "Echo. echo backup completed !!! >>% BACK_FULL_NAME % _ bat. the log echo completion time is % DATE % time %> % BACK_FULL_NAME % _ bat. log echo =================== the data on the backup server SZYY is complete !!! ==================>> % BACK_FULL_NAME % _ bat. log if not exist % BACKUP_WAREHOUSE % \ % BACK_NAME % _ LOG md % BACKUP_WAREHOUSE % \ LOG move % BACKUP_DIR % \*. log % BACKUP_WAREHOUSE % \ LOG \ rem Delete the rar backup file forfiles/p % BACKUP_WAREHOUSE % \ DMP/s/m * seven days ago *. rar/d-% delDays %/c "cmd/c del @ file" echo.