[[email protected] ~]$ ls Desktop oracle_backup.rman oracle_backup.sh
[[email protected] ~]$ cat oracle_backup.rman run{ CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/backup/%F‘; ALLOCATE CHANNEL CH1 DEVICE TYPE DISK FORMAT ‘/u01/backup/%U‘; ALLOCATE CHANNEL CH2 DEVICE TYPE DISK FORMAT ‘/u01/backup2/%U‘; BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10 PLUS ARCHIVELOG FILESPERSET 20 DELETE ALL INPUT; RELEASE CHANNEL CH1; RELEASE CHANNEL CH2; } ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK; CROSSCHECK BACKUPSET; DELETE NOPROMPT OBSOLETE;
[[email protected] ~]$ cat oracle_backup.sh #!/bin/bash export ORACLE_SID=orcl export log="/u01/$ORACLE_SID+`date +%y%m%d%H%M`" rman target / msglog $log cmdfile="/home/oracle/oracle_backup.rman"
然后可以通过计划任务定时进行备份执行oracle_backup.sh。
时间: 2024-11-09 10:16:32