Oracle backup with RMAN

Oracle backup with RMAN

Deploying an Oracle database is one thing, but doing a good recovery backup plan is another matter. Good for us, Oracle comes with its own tool for doing backups called “RMAN”.

Sure, one can do backup with the Enterprise Manager, but with it you will need to shut down the database in order to do a backup. Not exactly, what is needed with a production database that is online 24/7 and can’t afford a shutdown. In order to do a “online backup” one needs to run a script for RMAN.

RMAN uses the same login settings as your SQLPLUS login and thus it should be rather easy to do so. In our case we have also configured a backup catalog within Oracle with its own tablespace. Once done a backup script can be run each night with crontab.

Here is how to setup the backup catalog:

sqlplus sys
SQL> create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;

in case you don’t have a tablespace called “tools” you need to create it with:

create tablespace tools
logging
datafile '/dbf1/tools.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

Now you can log in to RMAN create the catalog schema with:

rman catalog rman/rman
RMAN> create catalog tablespace tools;
RMAN> exit;

Then register the database with;

rman catalog rman/rman target sys/password@ORCL
RMAN> register database;

Make sure you connect to the database that you need to backup!

I then created a script that will keep my backup for 2 days. I also have a script that will compress the backup files and move them to another server. Here is my backup script:

CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/opt/oracle/backup/autobackup_control_file%F';
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
run {
ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
CROSSCHECK BACKUP;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT
'/opt/oracle/backup/databasefiles_%d_%u_%s_%T';
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT
'/opt/oracle/backup/archivelogs_%d_%u_%s_%T' DELETE INPUT;
BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT
'/opt/oracle/backup/controlfile_%d_%u_%s_%T';
CROSSCHECK BACKUP;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED BACKUP;
RELEASE CHANNEL RMAN_BACK_CH01;
}
exit;

This will backup your control file, archive log and database. It will also compress the backup and will remove the old files.

In my case, I saved the above script as RMA_backup.txt and have a RMAN_script.sh with the following inside:

#!/bin/bash
rman target sys/password@ORCL @/opt/rman_backup.txt;

Troubleshooting
I have seen that sometimes we got errors running the above script with:

RMAN-06207: WARNING: 5 objects could not be deleted for DISK channel(s) due
RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects

With RMAN you can check your backup with the following commands:

CROSSCHECK backup of database;
CROSSCHECK backup of controlfile;
CROSSCHECK archivelog all;

If all goes well, you should not get any errors running these commands. Still we had the above errors, even thought I issued the command to delete obsolte control files with;

DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS;

The key to success was when I used the “FORCE” command as;

DELETE FORCE NOPROMPT OBSOLETE RECOVERY WINDOW OF 2 DAYS;

Hope this helps anybody. There is a good reference for backups over at the Oracle FAQ.

Helpmonks All-in-one Customer Service Platform
How to create a virtual machine server image from a physical CentOS server

I run a couple of servers over at a server farm. All of those machines run VMWare ESX, so today I wanted to move my last physical server to a VMWare image. If you want to convert a physical Windows machine then your task is quite easy. Start up the…

Helpmonks All-in-one Customer Service Platform
OpenBD and MongoDB: Can't get easier then this

I'm currently working on a project that uses MongoDB (yes, that's the awesome NoSQL database everyone talks about). Now, my favorites language of choice (CFML) and especially my favorite open source CFML engine OpenBD, has support for MongoDB built in which makes it a snap to use for any ColdFusion…

Helpmonks All-in-one Customer Service Platform
Announcing Razuna 1.9.5

As outlined in my last post, Razuna is going strong, and we see that many customers take to Razuna, which after all is still one of the best open source alternatives to any Enterprise Digital Asset Management. Today, I’m thrilled to announce the immediate availability of Razuna 1.9.5. Razuna 1.9.5, despite…

Helpmonks All-in-one Customer Service Platform
Why Coldfusion / CFML has its place and is worth to learn it

I actually never indulge in conversations why one programming language is better then another, because what is right to you, does not automatically mean, it is right for someone else. So, for me ColdFusion, or as we call the language itself - CFML, works very well. Nevertheless, in this post…

Helpmonks All-in-one Customer Service Platform
Updating Confluence and Jira is a nightmare and keeps you hunting for solutions

First off, I really like Jira and Confluence and we have been using them successfully for all our open source applications. We also use HipChat for our IM communication and use SourceTree for managing code on Github. Just realised that Atlassian has become a company to depend on... This post…

Helpmonks Cloud Servers
Introducing a low-cost GDPR-compliant dedicated shared inbox server

In these trying economic times, it is of utmost importance that your team can rely on a partner that makes sure that your communication with your clients continues without a hitch. After all, the current situation is stressful enough for all of us. With that in mind, we are introducing…

Trusted by over 2,000 organizations with millions of emails

Helpmonks helps us answer customer emails at lighting speed
We couldn't do our job without Helpmonks!
Helpmonks, the best thing since sliced bread
Excellent option for collaborating email amongst your team
A good platform that is here to grow and help you grow
Helpmonks is a great tool that our company utilizes and depends on
Great shared inbox for the team
Fantastic email support service for any business
Easy to navigate and catalog data for specific users
Solid Helpdesk software w/ responsive customer support
A really good solution to manage customer support mailbox
Good support, useful features

One more thing...

Helpmonks gives you the ability tocollaborate as a groupin your shared mailbox, features aTeam To-Do App, powerfulCustomer Relationship Management (CRM)capabilities, integratedLive-Chatand Email Marketing Tools for email newsletter and automated email campaigns, collision detection, email tracking, reminders, mentions, custom fields, custom applications, customer satisfaction ratings, Single-Sign-On (SSO) & SAML authentication, Trello, Zapier, Slack, an API, and much more.

Check outthe complete feature listor sign up for afree 30-day shared inbox trial now