Shell Script to Backup Oracle database using RMAN

How to create a shell script in Linux to backup Oracle database using RMAN?

Linux Shell Script to Backup Oracle database using RMAN

First of all, I have created a shell script named backup_script.sh which contains the actual sequence of commands to backup the database.

[oracle@testmn ~]$ cat backup_script.sh
run
{
crosscheck backup;
delete expired backup;
delete obsolete;
allocate channel ch1 type disk;
backup database format '/backups/hot_backups/daily_bk_%d_%T_%U';
backup archivelog all format '/backups/hot_backups/archivelog_%d_%u_%s_%T' not backed up 2 times;
delete noprompt archivelog all backed up 5 times to disk completed before 'sysdate-7';
release channel ch1;
}

[oracle@testmn ~]$
 

Now, I have created another shell script named rman_exe.sh which will start the RMAN session and call the above shell script as the above created shell script.

[oracle@testmn ~]$ cat rman_exc.sh
#!/bin/bash
rman target/ @/home/oracle/backup_script.sh

[oracle@testmn ~]$

Now, run this script checking whether it's working:

[oracle@testmn ~]$ sh rman_exc.sh

Linux Tips

See Also
Shell Script to Analyze Schema

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Home Index
Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.