Regular oracle database backup and oracle Database Backup
Currently, we need to design a batch of processing files to achieve full backup on Monday, Incremental backup on Tuesday, Friday, and Incremental backup on Thursday and Sunday. In addition, the daily data of the previous month is deleted on a daily basis (for example, the data of the current month is deleted on February 1,), and the backup is compressed to reduce the occupied space.
Ideas:
Backup: 1) delete data from the previous month.
2) execute different backup commands by judging the day of the week.
3) Add the backup file to the compressed package.
4) Delete the backup file.
Restore: if there is a problem with the database on Saturday, you need to import all the backups on Monday, the accumulated backups on Thursday, and the incremental backups on Friday.
Backup code:
@ Rem: delete the history backupsdel/f/s/q F: \ backup \ * % date :~ 8, 22.16.zip @ rem: create the new backupsif "% date :~ 12,1% "=" 1 "exp XXXXXX/XXXXXX inctype = complete file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12,1% "=" 2 "exp XXXXXX/XXXXXX inctype = incremental file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12,1% "=" 3 "exp XXXXXX/XXXXXX inctype = incremental file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12,1% "=" 4 "exp XXXXXX/XXXXXX inctype = cumulative file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12,1% "=" 5 "exp XXXXXX/XXXXXX inctype = incremental file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12, 1% "=" 6 "exp XXXXXX/XXXXXX inctype = incremental file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmpif "% date :~ 12,1% "=" 7 "exp XXXXXX/XXXXXX inctype = cumulative file = f:/backup/% date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmp @ rem: take the backups to zip "E: \ Program Files (x86) \ WinRAR \ WinRAR.exe" a F: \ backup \ % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 22.16.zip F: \ backup \ % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. dmp @ rem: delete the new backupsdel/f/s/q F: \ backup \ * % date :~ 8, 2%. dmppause
Note: 1) because the compression software is required during compression, install winrar as much as possible, such as , but sometimes unexpected problems may occur.
2) In this batch, all generated files use the current time as the file name. Baidu or leave a message that you cannot understand.
Restore code:
Imp XXXXXX/XXXXXX inctype = restore FULL = y file = F: \ backup \ 20150807.dmp
Note: During restoration, you only need to modify the imported file name.
Log files are not set for import and export.