Unix shell script to do a cold backup
i want to do a coldback using a unix shell script.
the db capacity is around 12 Tb
wen the backup is done i need to zip it too.at this moment i dont want to copy to the disk.
kindly help me regarding this
thanks in advance
NK
i used something like this until recently:
#!/bin/bash
umask 0077
export ORACLE_HOME="/u01/app/oracle/product/10.2.0/webdb1"
export PATH="$ORACLE_HOME/bin:$PATH"
export NLS_LANG="AMERICAN_AMERICA.WE8ISO8859P1"
db="dbname"
pipe="export.pipe"
file="$db-`date "+%Y-%m-%d"`.dmp"
if [ ! -p $pipe ]; then
## could exist but not be a pipe
rm -f $pipe
mknod $pipe p || (echo "could not create pipe $pipe"; exit 1)
fi
gzip -c > $file.gz < $pipe &
exp system/****@$db FULL=Y CONSISTENT=Y FILE=$pipe DIRECT=Y GRANTS=Y
you could of course also use zip|bzip2|pbzip2 or whatever.
hth, rgds, armin walland
Similar Messages
-
Generate RMAN backup Script using unix shell script
Hello,
Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
e.g.
rman.conf
CHANNELS=4
USE_CATALOG=Y
DEVICE='sbt_tabe'
etc.,
many thanks,
kamYou can actually encapsulate the RMAN commands inside the shell script.
However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
Thus, for example,
echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
echo "backup database plus archivelog" >> RMAN_Script.rmn
echo "backup archivelog all" >> RMAN_Script.rmn
creates RMAN_Script.rmn with 3 commands. -
Need Help in creating Unix Shell Script for database
Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
Here is the condition which i want to implement.
1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
2. Increase size of redolog file.
3. Load sample schema.
4. dump the schema.
5. Create empty db (Script should check if db already exists and drop it in this case).
6. Create backup using rman.
7. restore backup which you have backed up.This isn't much of a "code-sharing" site but a "knowledge-sharing" site. Code posted me may be from a questioner who has a problem / issue / error with his code. But we don't generally see people writing entire scripts as responses to such questions as yours. There may be other sites where you can get coding done "for free".
What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
But the expectation here is for you to write your own code.
Hemant K Chitale -
Calling a report from unix shell script
Hi,
I had to call a report from unix shell script.
May i know the procedure to accomplish this
Thanks in Advance
A.GopalFirst you should not include the whole path to your report in the call ...
Use like this:
/ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
In $ORACLE_HOME/bin/reports.sh:
1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
i.e.
Change the following line:
<!--trace traceOpts="trace_all"/-->
to <trace traceOpts="trace_all"/>
Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look. -
How can i call a Stored Procedure procedure from Unix shell script
Hi All,
I want to call a Strored PL-SQL Procedure through Unix shell script.
Can any body help me with this.
Regards,
SaurabhI prefer a seperate script like the other poster mentioned. However, most shells can use a 'here' document as well ...
sqlplus uid/pwd <<END
exec myproc
exit
ENDRichard -
Error while trying to execute a unix shell script from java program
Hi
I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
try {
File file_location = new File("/usr/bin/");
String file_location1 = "/opt/app/Hyperion/scripts/daily";
String a_mib_name = "test.sh";
String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
Runtime rtime = Runtime.getRuntime();
Process p = rtime.exec(cmd, null, file_location);
System.out.println( "Connected to the server1" );
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = br.readLine();
while(line !=null)
System.out.println(line);
line = br.readLine();
br.close();
p.getErrorStream ().close ();
p.getOutputStream().close();
int retVal = p.waitFor();
System.out.println("wait " + retVal);
//session.executeCommand("ls");
catch (IOException ex) {
I get an error message
Connected to the server
java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
): CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at SftpConnect.main(SftpConnect.java:143)
Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
e path specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
I am sure of the file path where the bash.sh and test.sh are located.
Am i missing something? Any help would be greatly appreciated.
Thanks
SenthilHi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
Mycode:
String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(command);
int exitVal = proc.exitValue();
System.out.println("Process exitValue: " + exitVal);
java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at DecryptTest.main(DecryptTest.java:18)
Can anyone please help -
Error while executing unix shell script from java program
Hi All,
I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
Code snippet :
Java Class :
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
}Test.ksh
export -- application realated paths..
nohup abc.exe 1> test.log 2>&1;
$1
exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
and able generate the logs properly.
Pls let us know where exactly i am stuck..
Thanks in advance,
Regards,
SatishHi Sabre,
As per the guidelines provided by the article, i had done below changes..
InputStream is = null;
InputStreamReader iStreamReader = null;
BufferedReader bReader = null;
String line = null;
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
is = proc.getErrorStream();
iStreamReader = new InputStreamReader(is);
bReader = new BufferedReader(iStreamReader);
System.out.println("<ERROR>");
while((line = bReader.readLine()) != null)
System.out.println("Error is : "+line);
System.out.println("</ERROR>");
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
Now , it's showing something like..
<ERROR>
</ERROR> -
Reg: UNIX shell script at File Adapter
Hi all,
I am doing a File to file scenario and using command line arguments in Sending file adapter. I am using UNIX shell script ".sh" file for executing the command.
I gave the following path at "Run OS command before message processing" parameter:
/temp/xidelivery/send/FILOSC004_shell.sh
and this file contains following code:
<b>#!/user/bin/sh cp /temp/xidelivery/send/FILOSC004_in.txt /temp/xidelivery/send/FILOSC004_input_copy4.txt</b>
I put the source file, FILOSC004_in.txt and shell script files at the respective paths.
If I give "cp" command directly in command line it is working fine. But I could not execute this with shell script. Can any body give me the reason where I gone wrong.
Regards,
Pavani.Hi,
can you try this,
bash /temp/xidelivery/send/FILOSC004_shell.sh
let me know.
hey you can check the blog below to catch the OS errors,
/people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
Prasad Babu.
Message was edited by:
PrasadBabu Koribilli -
Sending email attachments using unix shell script
hi
I want to send report generated my spooled file as attachment using unix shell script.
Can somebody help me out ?
many thanksthanks a tonn it worked.
but i have another issue is it possible to add names in CC also ?
Also here is my code which spools the output of SP to a txt file. the File name is generated dynamically.
as shown below:
I need to send this generated file as attachement.
how do I do this? Here the shell script
=========================================================
#!/bin/sh
ORA_USER=scott
ORA_PWD=tiger
#Get the input parameter
if [ ! "$1" ]; then
STR="NULL"
else
STR="'"$1"'"
fi
#echo "exec pkg1($STR);"
#Connecting to oracle
sqlplus -s <<EOF
$ORA_USER/$[email protected]
---sql plus enviornment settings
set linesize 160
set pagesize 60
set serveroutput on size 1000000 for wra
set feedback off
set termout off
column dcol new_value mydate noprint
select to_char(sysdate,'YYYYMMDDHH24MISS') dcol from dual;
spool &mydate.report.txt
exec pkg1($STR);
spool off
EOF
exit
=========================================================
the file name will take sysdate as name so that every time a new file will be generated.
this file I need to send as attachment.
null -
Calling stored procedure from unix shell script
Hello,
I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
Here is the code-
#!/bin/sh
OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
set serveroutput on;
var prd_out varchar2(100);
exec create_pm_window(:prd_out);
exit;
ENDOFSQL`
echo " output is - $OUTPUT"
The problem is :prd_out is not getting copied to shell variable OUTPUT.
I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
Any help is really appreciated.
Thanks'
RakheeFirst step :
make sure the PL/SQL works as expected.
Does the following display the expected output executed from SQL*Plus ?
set serverout on
declare
prd_out varchar2(100);
begin
create_pm_window(prd_out);
dbms_output.put_line('output is '||prd_out);
end;
I don't have your procedure, but using a dummy procedure like :
Scott@my10g SQL>create procedure foo(p_out in out varchar2)
2 is
3 begin
4 select 'Hello '||instance_name into p_out from v$instance;
5 end;
6 /
Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
var mavar varchar2(100);
exec foo(:mavar);
print mavar;
exit;
EOF`
echo "OUT = ${OUTPUT}"
exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
OUT = Hello my10g -
Please provide me unix shell script (export and import of database schema)
please i am new in unix
\please give me sample unix shell script (export and import of database schema)please i am new in unix
\please give me sample unix shell script (export and import of database schema)Instead of providing you the readymade unix shell script for your requirement, I will give you the hints to prepare the same at your own.
Create a file with .sh extension.
# Specify and set all required Environment variables.
ORACLE_HOME, PATH, NLS_LANG, etc.,
# Use the export command with all clauses
export scott/tiger@orcl file=scott.dmp log=scott_emp.log
# Compress it.
compress scott.dmp
Refer any unix/linux documents for scripting basics.
http://www.bijoos.com/ora7/oracle_unix.htm
Regards,
Sabdar Syed. -
Unable to pass parameter in oracle procedure through unix shell script
Hi Experts,
I have oracle procedure where in I have to pass the value of procedure parameter through unix script.
Follwoing is the sample procedure which i tried to exceute from the unix.
Procedure:
create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) AS
sql_stmt varchar2(1000) := NULL;
v_count number := 0;
v_owner varchar2(100) := owner;
begin
sql_stmt:='select count(1) from '||v_owner||'.EMP@infodb where rownum<=10';
execute immediate sql_stmt into v_count;
DBMS_OUTPUT.PUT_LINE(sql_stmt);
DBMS_OUTPUT.PUT_LINE(v_count);
END;The script which I used is:
Unix
#!/bin/ksh
parm=$1
echo start
sqlplus -s scott@DEV/tiger <<EOF >>result_1.txt
set serveroutput on;
select '$parm' from dual;
exec owner.PRC_TESTING_OWNER('$parm');
EOFThe script is working fine that is i am able to pass to parameter value through unix shell script. :)
But if I want to pass the value of the owner in cursor , I am unable to pass this value through unix.
Following the procedure which i am trying to implement.
create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) IS
v_owner varchar2(100) := owner;
CURSOR main_cur IS
select
i.ROWID rid ,
emp_name,
deptid
from v_owner.employee;
CURSOR subset_cur(c_deptid NUMBER ) IS
SELECT *
FROM v_owner.DEPT d
where d.dept_id=c_deptid;
--##main loop
FOR i IN main_cur LOOP
FOR j IN subset_cur(i.deptid) LOOP
BEGIN
insert into v_owner.RESULT_TABLE
END;
END LOOP;
END LOOP;How can i pass parameter value of the stored procedure through unix script(that is "owner" in this case), when these parameter value is
used in cursor? :(
Can anybody help me regarding the same?
Thanks in Advance !! :DIt's not the parameter in the cursor that is the problem, it's that you are trying to use static SQL for something that won't be known until run time (the owner of the table).
You would need to use something like ...
declare
l_owner varchar2(30) := 'SCOTT';
l_ref_cursor sys_refcursor;
type l_ename_tab is table of scott.emp.ename%type;
l_ename_array l_ename_tab;
begin
open l_ref_cursor for
'select ename
from ' || l_owner || '.emp';
loop
fetch l_ref_cursor bulk collect into l_ename_array limit 10;
exit when l_ename_array.COUNT = 0;
for x in 1 .. l_ename_array.count
loop
dbms_output.put_line(l_ename_array(x));
end loop;
end loop;
close l_ref_cursor;
end;
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01 -
i have a doubt as to how to comment a line in a shell script as i have to do that in a config. file of Oracle 9i Application Server. Is it a "--" in a line. Please help.
regardsTry to use # as a comment in unix shell script.
The config files in Oracle AS are xml based so the comment
therefore is
<!-- This is a comment -->
Hope that helps. -
Schedule workbook using with Unix shell script
Hi,
Can we schedule workbook using with Unix shell script?
Thanks,
JayI can't imagine how.
1. You can schedule Disco workbooks via Disco itself.
2. You can schedule Disco workbooks to run and output in different file formats automatically via batch scheduler in Windows running Disco Desktop directly (or can user VBasic).
3. You can schedule Disco workbooks to run and output in different file formats automatically via a Java program running the Java Command Line interface.
Moving forward, Oracle has announced that with a further interfacing of Disco with XML Publisher, you'll be able to use Oracle Apps concurrent manager and scheduling. But that's coming supposedly at the end of this year.
And I think that's about it.
Russ -
Unix shell script run from pl/sql procedure
Hi Guru
I want to run unix shell script from pl/sql procedure. Actual I want to run it from developer 10g form.
Please guide me in this regards
Regards
JewelLook at the host or client_host builtins in the help
Maybe you are looking for
-
Can we restrict Page assets shown in Content Finder to match available cq drop targets?
We have defined a component that accepts drag-and-drop of user content, and the cq:DropTargetConfig node (under cq:editConfig > cq:dropTargets) defines groups=[page] because it accepts assets of type cq:Page not images. Our component is a copy of th
-
Error msg while using i pod touch on bose sounddock
i got an error msg while using my ipod touch on a bose sound dock... it is still working fine it just said error not comatible with i pod touch, was this just a little second glitch, everything is still working fine dock is brand new, is there anythi
-
How do I migrate settings in Illustrator after updating from CC to CC 2014?
I have just updated from CC to CC 2014 and was not given the option to migrate settings for Illustrator as I was for Photoshop. How can I do this?
-
Polish character "u0141" in sap business 2007A
I cant put polish character Ł but i can ł into any field of SAP normally i use shiftaltL no i need to use capslock + alt + l is there any hot key in SAP 2007?? what can we do to make this (shiftaltL) work
-
Does restoring an ipod classic (prior format on Mac) in Windows delete music?
Does restoring an ipod classic (which was previously formatted on a Mac) in Windows 7 delete the music already on ipod?