Search This Blog

Tuesday, March 6, 2007

User_managed_HOT_BACKUP_linux

Oracle Version : 10.2.0.1.0
Linux Version : Ver 3 update 4

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 6 19:44:02 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL> conn sys/oracle as sysdba
Connected.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 6
Current log sequence 8
SQL> REM change archive log mode.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218944 bytes
Variable Size 83887744 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 6
Next log sequence to archive 8
Current log sequence 8
SQL> REM archive log generate in FLASH_RECOVERY_AREA. >>i am configure FRA for database<<<
SQL> REM must sure DB_RECOVERY_FILE_DEST_SIZE have enough space.

SQL> alter system set db_recovery_file_dest_size = 5g;

System altered.

SQL> REM archive location is
SQL> show parameter db_recovery_file_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /home/oracle/oracle/product/10
.2.0/db_1/flash_recovery_area
db_recovery_file_dest_size big integer 5G

SQL> REM archive log format
SQL> show parameter log_archive_format

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string %t_%s_%r.dbf
SQL> set heading off echo off verify off feedback off linesize 150 pagesize 0
SQL> spool /home/oracle/hotbackup.sql
SQL> select 'alter tablespace ' ||tablespace_name||' begin backup;'
2 from dba_data_files;
alter tablespace USERS begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace SYSTEM begin backup;
SQL> select 'host cp '||name||' /home/oracle/backup/hot '
2 from v$datafile;
host cp /home/oracle/oracle/product/10.2.0/db_1/oradata/oracle/system01.dbf /home/oracle/backup/hot
host cp /home/oracle/oracle/product/10.2.0/db_1/oradata/oracle/undotbs01.dbf /home/oracle/backup/hot
host cp /home/oracle/oracle/product/10.2.0/db_1/oradata/oracle/sysaux01.dbf /home/oracle/backup/hot
host cp /home/oracle/oracle/product/10.2.0/db_1/oradata/oracle/users01.dbf /home/oracle/backup/hot

SQL> select 'alter database backup controlfile to ''/home/oracle/backup/hot/control01.ctl'';'
2 from dual;

alter database backup controlfile to '/home/oracle/backup/hot/control01.ctl';

SQL> select 'alter database backup controlfile to ''/home/oracle/backup/hot/control02.ctl'';'
2 from dual;

alter database backup controlfile to '/home/oracle/backup/hot/control02.ctl';

SQL> select 'alter database backup controlfile to ''/home/oracle/backup/hot/control03.ctl'';'
2 from dual;

alter database backup controlfile to '/home/oracle/backup/hot/control03.ctl';



SQL> select 'alter tablespace '||tablespace_name||' end backup;'
2 from dba_data_files;
alter tablespace USERS end backup;
alter tablespace SYSAUX end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace SYSTEM end backup;
SQL> spool off
SQL> set heading on echo on verify on feedback on
SQL> exit
[oracle@localhost ~]$ vi hotbkp.sh
[oracle@localhost ~]$ chmod 755 hotbkp.sh
[oracle@localhost ~]$ crontab -e
crontab: installing new crontab
[oracle@localhost ~]$ crontab -l
#Cold backup script every day 06:24 pm.log file generated in backup.log
24 19 * * * /home/oracle/coldbkp.sh > /home/oracle/backup.log

#Hot backup script every day 08:06 pm. log file generated in backup1.log
29 20 * * * /home/oracle/hotbkp.sh > /home/oracle/backup1.log


hope this helps
Taj

No comments: