Creating automated Full and Incremental backups with RMAN


1)Scriptlərimizi saxlamaq üçün scripts qovluğunu yaradırıq

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

cd /home/oracle/
mkdir Scripts

[/pcsh]

2)Daha sonra həmin qovluğa daxil olub rman_full.sh faylını yazırıq və aşağıdakı FULL backup scripini fayla yazırıq.

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

vi rman_full.sh
ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 0 database format '/home/oracle/backup/rman/FULL_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

[/pcsh]

4) Daha sonra inremental RMAN backup almaq üçün scripts papkasina girib fayl yaradırıq və aşağıdakı scripti ona yazırıq

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@valehnote scripts]$ vi daily_rman_inc.sh
 
ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 1 database format '/home/oracle/backup/rman/INC_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

[/pcsh]1) We are creating  scripts directory for storing our scripts

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

cd /home/oracle/
mkdir Scripts

[/pcsh]

2) To take full RMAN backups we create rman_full.sh file. Then write full backup script above to this file .

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

vi rman_full.sh
ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 0 database format '/home/oracle/backup/rman/FULL_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

[/pcsh]

4) To take incremental backups we creating this script in scripts directory

[pcsh lang=”bash” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@valehnote scripts]$ vi daily_rman_inc.sh
 
ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 1 database format '/home/oracle/backup/rman/INC_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

[/pcsh]

RMAN vasitəsilə avtomatik full və incremental backupların alınması


1)Scriptlərimizi saxlamaq üçün scripts qovluğunu yaradırıq

cd /home/oracle/
mkdir Scripts

2)Daha sonra həmin qovluğa daxil olub rman_full.sh faylını yazırıq və aşağıdakı FULL backup scripini fayla yazırıq.

vi rman_full.sh
ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 0 database format '/home/oracle/backup/rman/FULL_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

3) Aşağıdakı komandanı yazıb FULL RMAN backup scriptinin işləmə vaxtını təyin edirik .
İlk olaraq dəqiqə (41), sonra isə saat(01) daxil edilir. Yəni hər gün saat 01:41-də işləyəcək.

crontab -e
41 01 * * * sh /home/oracle/scripts/rman_full.sh > /tmp/rman_cron_full.log

4) Daha sonra inremental RMAN backup almaq üçün scripts papkasina girib fayl yaradırıq və aşağıdakı scripti ona yazırıq

[oracle@valehnote scripts]$ vi daily_rman_inc.sh

ORACLE_SID=DB11G
ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_HOME PATH
$ORACLE_HOME/bin/./rman target sys/db11g@$ORACLE_SID log /tmp/rman.log <<EOF
set encryption on identified by 'db11g_rman' only;
run
{
backup incremental level 1 database format '/home/oracle/backup/rman/INC_backup_OF_%d_ON_%D_%M_%Y_%s_%t.bkp' plus archivelog format '/home/oracle/backup/rman/ARC_%D_%M_%Y_%s_%t.bkp';
}
delete obsolete;
Y
EOF

3) Aşağıdakı komandanı yazıb FULL RMAN backup scriptinin işləmə vaxtını təyin edirik .
İlk olaraq dəqiqə (41), sonra isə saat(01) daxil edilir. Yəni hər gün saat 01:41-də işləyəcək.

crontab -e
41 02 * * * sh /home/oracle/scripts/daily_rman_inc.sh > /tmp/rman_inc.log