Oracle Database Backup
  • Post category:Uncategorized
  • Post comments:0 Comments

Each Oracle database approach may have it’s advantages and drawbacks. Consult your company DBA to find out what is more suitable.

On both methods is high advisable to set Oracle to make hot backups possible, permanently:

mkdir /backup/oracle_arc

sqlplus / as sysdba

SQL> shutdown immediate

SQL> LOG_ARCHIVE_DEST=‘/backup/oracle_arc

SQL> startup mount

SQL> alter database archivelog;

SQL> alter database open;

1. Rman Integration:1

For configuration purposes, this is how you connect to Rman command line console, from shell:

rman target /

You may want to show and maybe change some of the Rman configurations, i.e: the retention that will apply to the intermediate backups that Rman will store on disk:

RMAN> SHOW ALL;

Probably you want to set up a different retention for local Rman backup, since Bacula will copy them periodically to backup storage:

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;

Define the directory where Rman backups will be stored:

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/rman/full_%u_%s_%p’;

Create that directory: 

mkdir -p /backup/rman

Create a ClientRunBeforeJob script to Bacula run along with this server backup job. It should be similar to that:

echo “BACKUP COMPRESSED AS BACKUPSET DATABASE PLUS ARCHIVELOG;” | “rman target /”

It’s possible also to make incremental Rman backups, adding the following to the backup command:

INCREMENTAL LEVEL 0

Finally, make shure at least Bacula FileSet includes both directories:

/backup/rman

/backup/oracle_arc

2. Oracle Hot Backup:

  1. Set up Archiving mode like the topic caput2

  1. Create ClientRunBefore Job script to put Oracle in backup mode.3

E.g.: start-backup-mode.sh in /etc/bacula/scripts with the following:

#!/bin/bash

sqlplus /nolog <<EOF

conn sys/managger as sysdba

alter database begin backup; exit

EOF

  1. Script to leave backup mode.

E.g.: stop-backup-mode.sh, on the same folder:

sqlplus /nolog <<EOF

conn sys/managger as sysdba alter database end backup; exit

EOF

  1. Bacula Oracle User Running Scripts

Bacula needs to run the scripts as Oracle user. For this add to /etc/sudoers on the client machine:

Cmnd_Alias backup_ORACLE = /bin/su – oracle -c / opt/oraappl/scripts/start-backup-mode.sh, /bin/su – oracle -c /opt/oraappl/scripts/start-backup-mode.sh bacula LOCAL = NOPASSWD: backup_ORACLE

  1. Bacula configuration.

This is a likely FileSet:

FileSet {

Name = “Linux-Oracle” Include {

Options { signature = SHA1 }

File = /mnt/snap/var/oradata

File = /mnt/snap/opt/oraappl

File = /usr/local/bin/

File = /var/backup/oracle/arch/

File = /etc/oratab

}

}

And a likely job configuration:

Job {

Name = “oracle-hot”backup”“ Client = oracleserver-fd JobDefs = “DefaultJob”

RunBeforeJob = “sudo /bin/su – oracle -c /opt/oraappl/ scripts/start-backup-mode.sh”

RunAfterJob = “sudo /bin/su – oracle -c /opt/oraappl/ scripts/stop-backup-mode.sh”

FileSet = “Linux-Oracle”

}

Disponível em: pt-brPortuguês (Portuguese (Brazil))enEnglish

Leave a Reply