Oracle cold backup and Hot Backup scripts

Source: Internet
Author: User

Oracle cold backup and Hot Backup scripts cold backup scripts:

set feedback offset heading offset verify  offset trimspool offset echo offset time offset timing offset pagesize 0set linesize 200define dir='/backup/cold/mike';define diroutmike='/u01/scripts/coldscr/mikecoldout.sql';spool &diroutmikeselect '!cp '||name||' &dir' from v$datafile order by file#;select '!cp '||name||' &dir' from v$controlfile;spool off;shutdown immediate;@&diroutmikestartup;

 

The preceding scripts are stored in/u01/scripts/coldscr/mikecold. SQL. You can run this script in the database for cold backup. Hot Backup script:
set feedback off set pagesize 0 set heading off set verify off set linesize 100 set trimspool on set echo off set time off set timing offundefine mikedirundefine mikescpdefine mikedir='/backup/hot'define mikescp='/u01/scripts/hotscr/mikehotout.sql'declare        cursor cur_tablespace is select tablespace_name from dba_tablespaces where status <> 'READ ONLY' and contents not like '%TEMP%';        cursor cur_datafile(tn varchar2) is select file_name from dba_data_files where tablespace_name=tn;begin        for ct in cur_tablespace loop                dbms_output.put_line('alter tablespace '||ct.tablespace_name||' begin backup;');                        for cd in cur_datafile(ct.tablespace_name) loop                                dbms_output.put_line('! cp '||cd.file_name||' &mikedir');                        end loop;                dbms_output.put_line('alter tablespace '||ct.tablespace_name||' end backup;');        end loop;end;/

 

The preceding scripts are stored in/u01/scripts/hotscr/mikehot. SQL. You can run this script to perform hot backup during database running.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.