Need a script for daily backup of oracle archive file
Friends,
Daily i am taking the backup of oracle archive file.From server to local pc using ssh of the local pc. i want to automate the work which im doing currently. what i will do is..... localpc$ ssh 111.12.12.2 serverpc$ cd /oracle/archive/ serverpc$ scp ar0000123.arc ar0000124.arc 111.12.12.2:/backup/archive/ this is the daily work im doing for taking archive file backup. daily oracle will generate some 10-20 archive files depend upon the usage. so, how can i write a script to copy the latest files only. thanks sathyguy |
Hi sathguy,
What you will first need to do is set up SSH to not prompt you for a password. You can do this using public key authentication. Jeremy has written a tutorial about it here[1]. Then all you need to do is hack together a quick shell script to copy the files across and make it run everyday. Code:
#!/bin/bash
Now I'm not familiar with how Oracle files are backed up, but looking at the files you are copying, it would seem that they increment in value (filename changes). You can either specify *.arc, or use other commands to narrow down which files are copied. -Kristijan [1] - http://www.linuxquestions.org/linux/..._Keys_with_SSH |
thanks...but
if i place the script in /etc/cron.daily at what time it will run the script. i want to run my script daily 02:00 AM. how can i do that? Thanks |
How to pass a variable to a script?
Friends,
here is my script..... Quote:
I want to execute this script daily at 02:00 AM. so that i edited the crontab -e as.... Quote:
Now what i want is.... 1. is the steps are correct for crontab -e? 2. Is the script of the crontab will execute daily at 02:00 AM? 3. how can i rename the .log filename and .dmp file name daily according to the date. for example abc_2001 is today's date and month.how can i replace with the variable. thanks sathyguy |
I've merged your two threads on the same topic; please re-read
the rules, and keep your discussions in one place. Cheers, Tink |
sorry...i will not repeat it...
i solved half of the problem..... whey this rename is not working? # rename file.sh file2.sh when i run the above command. the file name is not chaning. please point me where im making mistake thanks sathyguy |
Quote:
00 02 * * * /u02/script/dailybkp.sh |
i want the exported file name as abc_2101.dmp and abc_2101.log (2101 is a date and month)
However "2101" is not easy to look for, "20070121" is (replace with '+%Y%m%d' below). Anyway, add date like this: Code:
#!/bin/bash -- In your case use "mv" instead of "rename". Search LQ or the internet for "Rute": you want help with basic commands. |
tredegar,
i have edited my post before you reply.... please see my previous post. |
Quote:
Quote:
|
ok forget everything....
i have got a solution....working...but i have few questions to UnSpawn... Step1: $crontab -e Quote:
$vi dailybkp.sh Quote:
2. If im not using "exit 0" anything harm? 3. will the crontab execute daily at 02:00 AM? Thanks Sathyguy |
ok forget everything....
i have got a solution....working...but i have few questions to UnSpawn. Phrasing it like that and addressing one person when asking questions seems a bit inconsiderate towards those that helped you with other solutions. Besides that person may not be around to answer. 1. what is the purpose of "exit 0"? It sets the exit status of the script to what humans read as "OK". 2. If im not using "exit 0" anything harm? No harm anything. 3. will the crontab execute daily at 02:00 AM? You just reposted what you got from Tredegar. Is there any reason to doubt his reply? And is there any reason for you not to actually test it yourself? Come on! |
sorry for the inconvenience which is happened in this thread by me.
I have tested the suggestions , its working fine. Thank you all. |
once again sorry for reopening this thread....i tested with cp command it was working fine...
so, i thought it should work for exp command also. but its not working....also its not throwing any error.... the crontab -e is having... 00 02 * * * exp userid=system/password@realdb file=/u02/test/n22.dmp log=/u02/test/n22.log owner=scott statistics=none also i have tested by calling the script. #!/bin/bash 00 02 * * * /u03/script/testbkp.sh it's not working but the below one is working.... 00 02 * * * cp /u02/test.txt /u02/test/test.txt also this one is also working.... #!/bin/bash 00 02 * * * /u03/script/testbkp.sh (there is a cp command inside this script) i listed the chkconfig --list crond crond 0,1,6 = off 2,3,4,5 are on what might be the reason? thanks sathyguy |
I found the problem in the profile.
i have to add one more line at the beginning of the script. Quote:
thanks |
All times are GMT -5. The time now is 05:38 PM. |