configure rman settings before starting backup
rman> connect target
rman> show all;
rman> configure retention policy to recovery window of 7 days;
RMAN> configure CONTROLFILE AUTOBACKUP on;
SQL> show parameter db_recovery_file;
look how to configure http://tlepsh.blogspot.com/2007/08/oracle-flash-recovery-area.html
move oracle archive mode http://tlepsh.blogspot.com/2007/08/moving-oracle-to-archive-mode.html
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure device type disk parallelism n; n=1,2,3...
RMAN> backup database plus archivelog;
RMAN> list backup summary;
Showing posts with label rman. Show all posts
Showing posts with label rman. Show all posts
Thursday, 22 November 2007
Flash recovery space usage
delete backed up archivelog
rman> backup archivelog all delete all input;
reclaim archived log
delete archivelog
rman> delete archivelog until time 'sysdate-2';
delete old backup
rman> report obsolote;
http://tlepsh.blogspot.com/2007/08/oracle-deleting-old-backup-from-rman.html
rman> delete expired backup;
RMAN> report obsolete;
RMAN> delete obsolete;
rman> backup archivelog all delete all input;
reclaim archived log
delete archivelog
rman> delete archivelog until time 'sysdate-2';
delete old backup
rman> report obsolote;
http://tlepsh.blogspot.com/2007/08/oracle-deleting-old-backup-from-rman.html
rman> delete expired backup;
RMAN> report obsolete;
RMAN> delete obsolete;
Oracle point in time recovery RMAN Backup Restore
Backup database
RMAN> connect target
RMAN> backup database;
# sqlplus hr/hr
SQL> create table new as select * from employees;
SQL> insert into new select * from new;
SQL> commit;
SQL> select count(*) from new;
COUNT(*)
----------
214
SQL> alter session set nls_date_format = 'dd-mm-yyyy hh24:mi';
SQL> select sysdate from dual;
SYSDATE
----------------
24-10-2007 18:47
# sqlplus / as sysdba
SQL> select * from v$log;
get sequence number
Create new records
SQL> insert into new select * from new;
SQL> select count(*) from new;
COUNT(*)
----------
428
RMAN> shutdown immediate;
Restore to a time
RMAN> startup mount;
RMAN> run {
2> restore database until time "to_date('2007-10-24 18:48','YYYY-MM-DD HH24:MI:SS')";
3> recover database until time "to_date('2007-10-24 18:48','YYYY-MM-DD HH24:MI:SS')";}
Check that
# sqlplus / as sysdba
SQL> alter database open resetlogs;
# sqlplus hr/hr
SQL> select count(*) from new;
COUNT(*)
----------
214
RMAN> connect target
RMAN> backup database;
# sqlplus hr/hr
SQL> create table new as select * from employees;
SQL> insert into new select * from new;
SQL> commit;
SQL> select count(*) from new;
COUNT(*)
----------
214
SQL> alter session set nls_date_format = 'dd-mm-yyyy hh24:mi';
SQL> select sysdate from dual;
SYSDATE
----------------
24-10-2007 18:47
# sqlplus / as sysdba
SQL> select * from v$log;
get sequence number
Create new records
SQL> insert into new select * from new;
SQL> select count(*) from new;
COUNT(*)
----------
428
RMAN> shutdown immediate;
Restore to a time
RMAN> startup mount;
RMAN> run {
2> restore database until time "to_date('2007-10-24 18:48','YYYY-MM-DD HH24:MI:SS')";
3> recover database until time "to_date('2007-10-24 18:48','YYYY-MM-DD HH24:MI:SS')";}
Check that
# sqlplus / as sysdba
SQL> alter database open resetlogs;
# sqlplus hr/hr
SQL> select count(*) from new;
COUNT(*)
----------
214
Oracle RMAN backup/restore
Backup database
RMAN> connect target;
RMAN> backup database;
RMAN> shutdown immediate;
delete files
# mv *.dbf backup/
restore database
RMAN> startup;
RMAN> restore database;
RMAN> connect target;
RMAN> backup database;
RMAN> shutdown immediate;
delete files
# mv *.dbf backup/
restore database
RMAN> startup;
RMAN> restore database;
Oracle tablespace Backup/Restore (OS backup)
I tested tablespace recovery.
Be sure your database in archive mode
SQL> archive log list;
SQL> select count(*) from hr.employees;
Begin backup.
SQL> alter tablespace example begin backup;
Check the tablespace in backup state
SQL> select * from v$backup;
Prepare hr account
SQL> alter user hr account unlock;
SQL> alter user hr identified by hr;
# sqlplus hr/hr
Make some changes
SQL> create table employees2 as select * from employees;
Backup your file (This means that if you put your database in backup state you can do filesystem backup for oracle)
# cp example01.dbf example01.dbf.backup
End backup mode
# sqlplus / as sysdba
SQL> alter tablespace example end backup;
Shutdown database, delete table and restore table
SQL> shutdown abort;
# rm example01.dbf
# sqlplus / as sysdba
SQL> startup
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/example01.dbf'
You want database to be open while you are restoring tablespace.
SQL> alter database datafile '/path/example01.dbf' offline;
SQL> alter database open;
Restore tablespace and recover it
# mv example01.dbf.backup example01.dbf
SQL> recover tablespace example;
SQL> alter tablespace example online;
Verify recovery
# sqlplus hr/hr
SQL> select count(*) from employees2;
Be sure your database in archive mode
SQL> archive log list;
SQL> select count(*) from hr.employees;
Begin backup.
SQL> alter tablespace example begin backup;
Check the tablespace in backup state
SQL> select * from v$backup;
Prepare hr account
SQL> alter user hr account unlock;
SQL> alter user hr identified by hr;
# sqlplus hr/hr
Make some changes
SQL> create table employees2 as select * from employees;
Backup your file (This means that if you put your database in backup state you can do filesystem backup for oracle)
# cp example01.dbf example01.dbf.backup
End backup mode
# sqlplus / as sysdba
SQL> alter tablespace example end backup;
Shutdown database, delete table and restore table
SQL> shutdown abort;
# rm example01.dbf
# sqlplus / as sysdba
SQL> startup
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/example01.dbf'
You want database to be open while you are restoring tablespace.
SQL> alter database datafile '/path/example01.dbf' offline;
SQL> alter database open;
Restore tablespace and recover it
# mv example01.dbf.backup example01.dbf
SQL> recover tablespace example;
SQL> alter tablespace example online;
Verify recovery
# sqlplus hr/hr
SQL> select count(*) from employees2;
Oracle Offline Database Backup/Restore (OS backup)
I did some tests. Here I backed up oracle and do some changes. Later I restored with copying files. You can just copy or use any backup software.
Backup
RMAN> connect target;
RMAN> shutdown immediate;
copy oracle datafiles to backup directory
#cp -R /oracle_datafiles_dir/* /backup_dir/
remove redolog files
#rm redo*.log /backdir
Break down your database
open database and do some changes
RMAN> startup;
shutdown database and delete datafiles
RMAN> shutdown immediate;
#rm /oracle_datafiles_dir/*.dbf
Restore
Move backup files to original directory
#cp -R /backup_dir/* /oracle_datafiles_dir/
start database
RMAN> startup mount;
RMAN> recover database until cancel;
RMAN> alter database open resetlogs;
You do not have to do last two steps if you backup redo logs and restore it.
Backup
RMAN> connect target;
RMAN> shutdown immediate;
copy oracle datafiles to backup directory
#cp -R /oracle_datafiles_dir/* /backup_dir/
remove redolog files
#rm redo*.log /backdir
Break down your database
open database and do some changes
RMAN> startup;
shutdown database and delete datafiles
RMAN> shutdown immediate;
#rm /oracle_datafiles_dir/*.dbf
Restore
Move backup files to original directory
#cp -R /backup_dir/* /oracle_datafiles_dir/
start database
RMAN> startup mount;
RMAN> recover database until cancel;
RMAN> alter database open resetlogs;
You do not have to do last two steps if you backup redo logs and restore it.
Subscribe to:
Posts (Atom)