Nethence Newdoc Olddoc Lab Your IP BBDock  

Warning: those guides are mostly obsolete, please have a look at the new documentation.


Oracle RMAN -- Setting up a backup strategy
We're assuming RMAN catalog is up and the database you want to backup is already registered into it. Prepare the backup dir someplace on the server containing the database you want to backup, as oracle user,
mkdir -p /u03/backup
Backup modes & levels
Cumulative incremental backups (level 1)
(elsewhere called differential backup)
Differential incremental backups (level 2)
(elsewhere called incremental backup)
Backup levels
Level 0 is the base for any other backup (full backup)
Level 1 backups any change since the last level 0 backup.
Level 2 backups any change since the last level 0, 1 or 2 backup
Archivelog mode on the target databases
Make sure archive logs are enabled,
archive log list
select log_mode from sys.v$database;
To enable archive logs, you need to restart the instance,
shutdown immediate
startup mount
alter database archivelog;
--alter database noarchivelog;
alter database open;
You may also want to enlarge the flash recovery area limit a little (2G by default),
alter system set db_recovery_file_dest_size=10G scope=both;
show parameter db_recovery_file_dest_size;
grep -a recovery $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
RMAN catalog configuration
On the server containing the database or on the server containing the catalog, define the retention policy and enable controlfile autobackup,
rman target sys/PASSWORD@dbname catalog cat/CATPASSWD@rcat
show all;
configure retention policy to recovery window of 20 days;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/u03/backup/dbname/ctautobkp_%F';
Note. careful those defaults take precedence
Note. controlfile autobackup so that control files get backed up even if it's not a full backup
Note. spfile will be included in the controlfile autobackup backupset
Note. "show all" gives you the content of the RMAN catalog configuration, that's all there is in here, but some pieces are also put inside databases' contolfiles.
Note. we don't force the backup device (disk is the default anyways)
#configure default device type to disk;
Note. we don't force the path destination for backups (we use our scripts)
#configure channel device type disk format '/u02/backup/db_%d_S_%s_P_%p_T_%t';
Note. alternate retention policy configuration,
configure retention policy to redundancy 2;
With the retention policy you will then be able to purge,
report obsolete;
#report obsolete recovery window of 7 days;
delete expired backupset;
Backup script
Deploy this script,
cd ~/bin
vi _backup
chmod +x _backup
Schedule the jobs as oracle user,
crontab -e
0 1 * * sun $HOME/bin/_backup full
0 1 * * mon,tue,wed,thu,fri,sat $HOME/bin/_backup incr
0 12 * * mon,tue,wed,thu,fri,sat $HOME/bin/_backup incr
Block change tracking
Available since 10g, Change Block Tracking will speed up incremental backups,
mkdir /u02/oradata/tracking
. oraenv
sqlplus / as sysdba
select * from v$block_change_tracking;
alter database enable block change tracking using file '/u02/oradata/tracking/dbname.track';
select * from v$block_change_tracking;
Note. only for Oracle Enterprise, otherwise you get a,
ORA-00439: feature not enabled: Block Change Tracking
Note. otherwise,
#mkdir /u02/oradata/dbname.files
--alter system set db_create_file_dest='/u02/oradata/dbname.files';
--alter database enable block change tracking;

(obsolete, see the new doc)