Home » RDBMS Server » Backup & Recovery » Script for Schedule Backup.
Script for Schedule Backup. [message #243396] Thu, 07 June 2007 03:54 Go to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

I use linux pc. Oracle is installed in Solaris pc. I need the script of RMAN incremental Backup level 0 that will be scheduled to run every week at 3 am. Also I need incremental Backup level 1 in every day. How can I backup and restore the database?

Can I restore database for example as it was at saturday 12 pm?

Thank you in advance.
Re: Script for Schedule Backup. [message #243397 is a reply to message #243396] Thu, 07 June 2007 03:56 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

I use oracle 10g.2
Re: Script for Schedule Backup. [message #243411 is a reply to message #243396] Thu, 07 June 2007 04:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Did you already read the examples in Oracle documentation?

Regards
Michel
Re: Script for Schedule Backup. [message #243417 is a reply to message #243396] Thu, 07 June 2007 04:30 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

Yes I already read. I can make just instant rman backup and restore(that is I give command in rman and wait for 2 hours to complete it ) it of both base level and incremental level backup. But I want a schedule script that will run automatically everyday without any user prompt.
Re: Script for Schedule Backup. [message #243419 is a reply to message #243417] Thu, 07 June 2007 04:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use dbconsole, it allows you to do it in few clicks.

Regards
Michel
Re: Script for Schedule Backup. [message #243425 is a reply to message #243396] Thu, 07 June 2007 04:52 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

Michel ok we can do that by EM.

But can we schedule this from rman prompt or will this command will work if database is archivelog mode and open?

like for backup,

rman> backup incremental level 0 device type disk format '/backup/%U' tag base_backup database;

rman> backup incremental level 1 device type disk format '/backup/%U' tag first_incr_backup database;

suppose to restore lastest backup in database open mode will this singla command work..?

rman> restore database with tag first_incr_backup;

Re: Script for Schedule Backup. [message #243430 is a reply to message #243396] Thu, 07 June 2007 04:58 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

I know that I am disturbing u much. Sorry, I am a new member in this era. Can you please help me by providing the address of document about oracle EM from which i know step by steps to perform rman backup & recovery.
Re: Script for Schedule Backup. [message #243450 is a reply to message #243425] Thu, 07 June 2007 05:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
RMAN does not have a scheduler. You have to use RDBMS or OS one.

You don't restore a database in open mode, you have to be in mount mode.
You can restore tablespace in open mode (but system or undo ones).

Regards
Michel
Re: Script for Schedule Backup. [message #243452 is a reply to message #243430] Thu, 07 June 2007 06:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Arju,


Have a look at Database 2 Day DBA

Regards
Michel

Re: Script for Schedule Backup. [message #243455 is a reply to message #243396] Thu, 07 June 2007 06:08 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

You are really helping me much than I expected. Ok brother, one thing can I recover my database by mentioning a prior time. Suppose I want to go to the state in the database as it was in 4th June, 2007 6:00am .. Is it possible? I have oned my flashback feature and I run my database in archive log mode.
Re: Script for Schedule Backup. [message #243457 is a reply to message #243455] Thu, 07 June 2007 06:09 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Create a new topic for this.
It is not the same question that OP's one.

Regards
Michel
Re: Script for Schedule Backup. [message #243512 is a reply to message #243457] Thu, 07 June 2007 10:34 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
Connect with rman then create the script like this
create script xxx_backup_whole
 {
  allocate channel ch1 type disk format '$GAM_ORABACKUP/%U.bck';
  allocate channel ch2 type disk format '$GAM_ORABACKUP/%U.bck';
  allocate channel ch3 type disk format '$GAM_ORABACKUP/%U.bck';
  set limit channel ch1 kbytes 2024800;
  set limit channel ch2 kbytes 2024800;
  set limit channel ch3 kbytes 2024800;
  backup database;
  sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
  backup archivelog all format '$GAM_ORABACKUP/al_%U.bck';
  backup current controlfile
  tag = cf1
  format '$GAM_ORABACKUP/cf_%U.bck';
 }


then create a file in OS like
vi daily_backup.com
and put the enteries like this

#!/bin/ksh
. $HOME/.profile_dbname
rman target system/manager catalog rman/rman@RCATO log $xxx_ORABACKUP/mlog.f << rman_exit
run { execute script xxx_backup_whole; }
exit
rman_exit




then make the entry for this in crontab

00 18 * * * /export/home/oracle/abc7.2/script/daily_backup.com > /export/home/oracle/abc7.2/script/daily/log/daily_backup.log &
Re: Script for Schedule Backup. [message #388429 is a reply to message #243512] Tue, 24 February 2009 12:58 Go to previous messageGo to next message
ridhi_sundar
Messages: 184
Registered: November 2007
Location: Bangalore
Senior Member
Can someone tell me what is the .profile_dbname in the above example?

And I couldn't understand why the << rman_exit is there.

Regards
Ridhi Sundar
Re: Script for Schedule Backup. [message #388431 is a reply to message #243396] Tue, 24 February 2009 13:05 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>And I couldn't understand why the << rman_exit is there.
In UNIX-speak, it is called a "here script"
The here script starts with the line which contains "<<"
& continues until it reaches the line which begins with the string to the right of the " << " characters;
in this case to the containing "rman_exit".
One BIG advantage of HERE SCRIPT is that shell variable substitution occurs before the script is actually run.
Re: Script for Schedule Backup. [message #388982 is a reply to message #388431] Thu, 26 February 2009 20:37 Go to previous message
trantuananh24hg
Messages: 744
Registered: January 2007
Location: Ha Noi, Viet Nam
Senior Member
Some ways to scheduler backup using rman, and DreamzZ gave you one.

In NT, you can write rman's script, put it in a bat file, and scheduler the bat file with NT's system tool (or command line).

In Unix, you can write rman's script, put it-the file_name in a executable file, in which, content is very simple, such as:

-- rman's script
$ cat >> /u01/app/level0.rc <<EOF
> run{
> allocate channel d1 type disk format 
> '/u01/app/backupfull/level_0_%d_%s_%t.bkp'
> connect 'sys/pwdunix@sid;
> set limit channel d1 kbytes 1048576;
> crosscheck backup;
> sql 'alter system archive log current';
> backup as compressed backupset incremental level 0 database
> tag=sid_level_0
> plus archivelog delete input
> tag=sid_archive_level_0
> filesperset 4;
> delete obsolete;
> delete expired backup ;
> backup current controlfile 
> format '/u01/app/backupfull/controlfile_%d_%t.bkp';
> release channel d1;
> }
^D
$


-- Executable file
$ cat >> /u01/app/level0_execute <<EOF
> ~/.profile
> rman target sys/pwdunix@sid @/u01/app/level0.rc
^D
$ chmod +x /u01/app/level0_execute


Finally, you will make a job scheduler
-- Make a job scheduler by crontab utility
$ export EDITOR=vi
$ crontab -e 
...
20 03 * * 6 /u01/app/level0_execute
!wq 
$ crontab -l
20 03 * * 6 /u01/app/level0_execute


P/S:
- You should backup full in midnight or later, about 2-3am
- You will make yourself backup incremental level 1, put it in a crontab utility as above, and force to run it every day at 00am or later, depend yours.
- You can choose OS's utility (system_tool in NT or crontab in Unix) or you can make a job scheduler by DBMS_SCHEDULER. The DBMS_SCHEDULER could be different & difficult more than OS's utility, but it has a better idea: It-the scheduler execution file does not run if Database do not open, but OS does.
- My idea of BlackSwan's point is better than me to make a script file with DreamzZ script.

[Updated on: Thu, 26 February 2009 22:35]

Report message to a moderator

Previous Topic: Full export, smaller import file sizes
Next Topic: Recovery statement in standard Oracle backup Script ??
Goto Forum:
  


Current Time: Fri Nov 22 08:10:37 CST 2024