Home » Infrastructure » Linux » How to set backup automatically? (oracle, 12c, oraclelinux)
How to set backup automatically? [message #682731] Thu, 12 November 2020 19:28 Go to next message
solution
Messages: 13
Registered: November 2020
Junior Member
I have just .sh file. Now How can I set backup automatically?

export  ORACLE_SID=mydborcl
export  ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1
export  PATH=$ORACLE_HOME/bin:$PATH
export  NLS_LANG='AMERICAN_AMERICA.AL32UTF8'

expdp adminuser/Mypassword@mydborcl schemas=adminuser directory=my_db1 dumpfile=adminuser_`date +%Y%m%d`.dmp logfile=adminuser_`date +%Y%m%d`.log
Re: How to set backup automatically? [message #682734 is a reply to message #682731] Fri, 13 November 2020 00:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Have a look at cron.

Re: How to set backup automatically? [message #682737 is a reply to message #682734] Fri, 13 November 2020 01:28 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
Is it right?
00 02 *** /export.sh
How to set it every week?

[Updated on: Fri, 13 November 2020 01:30]

Report message to a moderator

Re: How to set backup automatically? [message #682738 is a reply to message #682737] Fri, 13 November 2020 02:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

What schedule do you want?
How can we answer the question "Is it right?" when we don't what you want?

Re: How to set backup automatically? [message #682739 is a reply to message #682737] Fri, 13 November 2020 04:37 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
solution wrote on Fri, 13 November 2020 07:28
Is it right?
00 02 *** /export.sh
How to set it every week?
That will never work. You have concatenated the three fields for day-of-month, month-of-year, and day-of-week into one. And you are trying to run a script in the root directory, which is somewhat unlikely. The script you have is not reliable either: at the very least you need a #! at the beginning to specify a shell.
Re: How to set backup automatically? [message #682740 is a reply to message #682739] Fri, 13 November 2020 06:24 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
Could you solve this it?
I am very new on linux.

I have to run the script every 02 am or every week.
Re: How to set backup automatically? [message #682741 is a reply to message #682740] Fri, 13 November 2020 08:09 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
solution wrote on Fri, 13 November 2020 06:24
Could you solve this it?
I am very new on linux.

I have to run the script every 02 am or every week.
They've given you all the clues.

First, you don't want to do ANYTHING as the root user, unless you ABSOLUTELY need that elevated level of privilege. You should have an OS user that owns the oracle installation. This user is usually named 'oracle'. Connect as 'oracle' and create your crontab from there.

Your crontab that you show indicates that your script is located in the root directory. Not a good place for it. You should have a directory owned by 'oracle' where you keep your oracle scripts. At the very least, /home/oracle/.

Your script should begin with a directive to indicate which shell (sh, ksh, bash, etc) you want to process your script. I usually use 'sh', so the directive is '#!/bin/sh'.

You said "I have to run the script every 02 am or every week." I *think* you meant "run the script at 02 am on every week." (I'll chalk that up to English not being your first language.) So, what day of the week? I could spoon feed you on that, but you'd learn far more by going back to a good reference on 'cron' and figuring it out. Present your best effort and we'll comment on it to nudge you to self-discovery.

BTW, you mentiond in the title that this is a 'backup' job. But your script is running expdp. I do hope that you are not relying strictly on exports as your only backup strategy. You really need to be using rman for your primary backup mechanism.
Re: How to set backup automatically? [message #682748 is a reply to message #682741] Sat, 14 November 2020 02:29 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
I thought "expdp" is full backup of database. Anyway I want to run the script on every day at 02 am.

Should I use 'rman' to do backup full db on everyday?
Re: How to set backup automatically? [message #682749 is a reply to message #682748] Sat, 14 November 2020 03:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
I thought "expdp" is full backup of database.

No it is a data and schema backup not a database level backup.


Quote:
Should I use 'rman' to do backup full db on everyday?

Yes, no, it depends on your restore and recover requirements but it is sure you should use RMAN to backup.
First read Database Backup and Recovery User's Guide, chapter 1 Introduction to Backup and Recovery.
First of all, are you in ARCHIVELOG mode?

[Updated on: Sat, 14 November 2020 03:21]

Report message to a moderator

Re: How to set backup automatically? [message #682750 is a reply to message #682748] Sat, 14 November 2020 03:18 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
The expdp utility invokes Data Pump. Data Pump is a tool for copying objects from one database to another. It does not protect the database against damage, such as a corrupted file.
Re: How to set backup automatically? [message #682756 is a reply to message #682749] Sun, 15 November 2020 22:46 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
Michel Cadot wrote on Sat, 14 November 2020 03:04

Quote:
I thought "expdp" is full backup of database.
No it is a data and schema backup not a database level backup.


Quote:
Should I use 'rman' to do backup full db on everyday?
Yes, no, it depends on your restore and recover requirements but it is sure you should use RMAN to backup.
First read Database Backup and Recovery User's Guide, chapter 1 Introduction to Backup and Recovery.
First of all, are you in ARCHIVELOG mode?

Sure. I am in ARCHIVELOG mode.

Can you provide to get the next step?
Re: How to set backup automatically? [message #682757 is a reply to message #682756] Sun, 15 November 2020 23:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Michel Cadot wrote on Sat, 14 November 2020 10:04

...
First read Database Backup and Recovery User's Guide, chapter 1 Introduction to Backup and Recovery.
...
Re: How to set backup automatically? [message #682759 is a reply to message #682757] Mon, 16 November 2020 19:36 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
Since I read I have to us RMAN backup job.
The set of BACKUP commands executed within a single RMAN session. For example, assume that you start the RMAN client, execute BACKUP DATABASE, BACKUP ARCHIVELOG, and RECOVER COPY, and then exit the RMAN client. The RMAN backup job consists of the database backup and the archived redo log backup.
Am I right?

[Updated on: Mon, 16 November 2020 19:37]

Report message to a moderator

Re: How to set backup automatically? [message #682760 is a reply to message #682759] Tue, 17 November 2020 00:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
Am I right?

Right about what?
About quoting Oracle documentation?
By the way, always post the link to what you quote.
It seems you quoted this from https://docs.oracle.com/cd/E18283_01/backup.112/e10642/glossary.htm#sthref2412, that is from 11.2 master glossary, this is not sufficient, read the link I posted.

Re: How to set backup automatically? [message #682769 is a reply to message #682760] Tue, 17 November 2020 19:56 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
Thank you bro. I found instruction of "Making an Archival Backup" and "Making a Temporary Archival Backup". Which I need to be used future?
Re: How to set backup automatically? [message #682770 is a reply to message #682769] Wed, 18 November 2020 01:21 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
One more time: you need to read the manual. This one,

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/bradv/index.html

Re: How to set backup automatically? [message #682778 is a reply to message #682769] Wed, 18 November 2020 08:45 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
solution wrote on Tue, 17 November 2020 19:56
Thank you bro. I found instruction of "Making an Archival Backup" and "Making a Temporary Archival Backup". Which I need to be used future?
"archival" backups are somewhat 'special purpose'. If you've never seen rman, and don't know which 'archival' you need, then I'd suggest you don't need either. You just need to set up a normal series of level 0 and level 1 incremental backups, along with backups of your archive logs. NOrmal 'textbook' practice is to take a level 0 backup once a week and a level 1 the other six days. Set recovery period to 7 days. I could spell it out in more detail, but you first need to go back to the cited references and try yourself. You learn nothing if I just give you a script and say "here, use this, it works".
Re: How to set backup automatically? [message #682779 is a reply to message #682778] Wed, 18 November 2020 10:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

He certainly needs to first read the link I provided and repeated.

Re: How to set backup automatically? [message #682782 is a reply to message #682779] Wed, 18 November 2020 12:08 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Michel Cadot wrote on Wed, 18 November 2020 10:06

He certainly needs to first read the link I provided and repeated.

Agreed. Hence, my statement "but you first need to go back to the cited references ".

Razz

[Updated on: Wed, 18 November 2020 12:08]

Report message to a moderator

Re: How to set backup automatically? [message #683049 is a reply to message #682778] Sun, 29 November 2020 20:52 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
EdStevens wrote on Wed, 18 November 2020 08:45
solution wrote on Tue, 17 November 2020 19:56
Thank you bro. I found instruction of "Making an Archival Backup" and "Making a Temporary Archival Backup". Which I need to be used future?
"archival" backups are somewhat 'special purpose'. If you've never seen rman, and don't know which 'archival' you need, then I'd suggest you don't need either. You just need to set up a normal series of level 0 and level 1 incremental backups, along with backups of your archive logs. NOrmal 'textbook' practice is to take a level 0 backup once a week and a level 1 the other six days. Set recovery period to 7 days. I could spell it out in more detail, but you first need to go back to the cited references and try yourself. You learn nothing if I just give you a script and say "here, use this, it works".
Can I use this script?
RUN {
   RECOVER COPY OF DATABASE WITH TAG 'incr_update' 
       UNTIL TIME 'SYSDATE - 7';
   BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update'
       DATABASE;
   }RUN {
   RECOVER COPY OF DATABASE WITH TAG 'incr_update' 
       UNTIL TIME 'SYSDATE - 7';
   BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update'
       DATABASE;
   }
Re: How to set backup automatically? [message #683050 is a reply to message #683049] Mon, 30 November 2020 00:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Michel Cadot wrote on Sat, 14 November 2020 10:04

...
Yes, no, it depends on your restore and recover requirements but it is sure you should use RMAN to backup.
First read Database Backup and Recovery User's Guide, chapter 1 Introduction to Backup and Recovery.
...
Re: How to set backup automatically? [message #683055 is a reply to message #683049] Mon, 30 November 2020 09:06 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Can you 'recover copy of database'? I don't know, can you? Did you study what those commands do and think about how they are used?

SHOULD you use that script. Probably not. It appears you are ignoring the link that Michael has posted multiple times. Then you jump into the deep end of some rather special purpose uses of rman.

You need a simple BACKUP of the DATABASE and ARCHIVELOGS. Along with some housekeeping to DELETE those backups that have become OBSOLETE.

Please re-read that paragraph. I have capitalized several key words. Those are actual rman commands or options for commands. Please read up on them in the previously cited manual. Please quit looking for someone to hand you a pre-written script on a platter. You learn nothing that way. Think about the purpose of a backup. Is it to be able to say "I'm backing up the database"? Or is it to provide a means of recovering the database it when it goes belly-up at 2:00 AM? When that happens, and your director is breathing down your neck to recover it from those backups you've supposedly been taking, you'd better have a sound understanding of how this works, not just a backup script someone gave you.
Re: How to set backup automatically? [message #683057 is a reply to message #683055] Mon, 30 November 2020 10:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
Or is it to provide a means of recovering the database it when it goes belly-up at 2:00 AM?

A clue: RMAN means Recovery MANager. Razz

[Updated on: Mon, 30 November 2020 10:32]

Report message to a moderator

Re: How to set backup automatically? [message #683058 is a reply to message #683057] Mon, 30 November 2020 14:35 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Michel Cadot wrote on Mon, 30 November 2020 10:31

Quote:
Or is it to provide a means of recovering the database it when it goes belly-up at 2:00 AM?
A clue: RMAN means Recovery MANager. Razz

Indeed! Else it would have been named BMAN, for Backup MANager.

Smile
Re: How to set backup automatically? [message #683059 is a reply to message #683049] Mon, 30 November 2020 14:37 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
BTW please note that you opened this thread wanting help with how to schedule a job with cron. We've drifted a long way from that subject.
Re: How to set backup automatically? [message #683094 is a reply to message #682737] Wed, 02 December 2020 07:16 Go to previous messageGo to next message
gazzag
Messages: 1119
Registered: November 2010
Location: Bedwas, UK
Senior Member
The 5th parameter is day of the week with 0 = Sunday and 5 = Friday.

HTH
-g
Re: How to set backup automatically? [message #683386 is a reply to message #683055] Wed, 06 January 2021 20:53 Go to previous messageGo to next message
solution
Messages: 13
Registered: November 2020
Junior Member
I found no luck until now.

@gazzag
Quote:
The 5th parameter is day of the week with 0 = Sunday and 5 = Friday.

HTH
-g
Can you write the full script of it?

EdStevens wrote on Mon, 30 November 2020 09:06

SHOULD you use that script. Probably not. It appears you are ignoring the link that Michael has posted multiple times. Then you jump into the deep end of some rather special purpose uses of rman.
.
Please provide me right section I need.
Re: How to set backup automatically? [message #683387 is a reply to message #683386] Thu, 07 January 2021 00:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Troll or dumb?

Re: How to set backup automatically? [message #683396 is a reply to message #683386] Thu, 07 January 2021 10:48 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
solution wrote on Wed, 06 January 2021 20:53
I found no luck until now.

@gazzag
Quote:
The 5th parameter is day of the week with 0 = Sunday and 5 = Friday.

HTH
-g
Can you write the full script of it?

EdStevens wrote on Mon, 30 November 2020 09:06

SHOULD you use that script. Probably not. It appears you are ignoring the link that Michael has posted multiple times. Then you jump into the deep end of some rather special purpose uses of rman.
.
Please provide me right section I need.
See the previously cited document. See section 9.3.1 Backing Up a Whole Database with RMAN
Be sure to back up the archivelogs as well.
Be sure to include the option to delete the archivelogs after they have been backed up. BTW, you previously asserted that you are in archivelog mode. What are you currently doing to prevent the archivlog destination from filling up?
Be sure to include command to delete obsolete backups.

In addition to the previously cited RMAN User Guide, you should also be reading the Database Backup and Recovery Reference.
Previous Topic: Oracle 11g XE installation in Debian
Next Topic: Missing Package: gcc-c++-3.4.6 (x86_64)
Goto Forum:
  


Current Time: Wed Dec 04 02:15:10 CST 2024