Thursday, January 20, 2011

Script to generate a hot backup copy script from any database

Script to generate a hot backup copy script from any database

set serveroutput on
set heading off
set feedback off
spool c:\scripts\backup.sql
declare
fname varchar2(55);
tname varchar2(55);
tname1 varchar2(55);
cursor tspaces is
select tablespace_name,file_name from v$datafile,sys.dba_data_files
where enabled like '%WRITE%' and file# = file_id order by 1
begin
dbms_output.enable(32000);
dbms_output.put_line('spool hotback');
open tspaces;
fetch tspaces into tname,fname;
tname1 := tname;
dbms_output.put_line('alter tablespace '||tname||' begin backup;');
while tspaces%FOUND loop
if tname1 != tname then
dbms_output.put_line('alter tablespace '||tname1||' end backup;');
dbms_output.put_line('alter tablespace '||tname||' begin backup;');
tname1 := tname;
end if;
dbms_output.put_line('!copy '||fname||' c:\VALEN\DBFILES\');
--Change the line above line with o.s specific copy command.
fetch tspaces into tname,fname;
end loop;
dbms_output.put_line('alter tablespace '||tname1||' end backup;');
close tspaces;
dbms_output.put_line('spool off');
end;
/
spool off
set heading on
set feedback on
set serveroutput off

 
Regards,
Sukhwinder Singh.

..

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

There was an error in this gadget