Oracle9i RMAN backup and recovery steps

Source: Internet
Author: User

I have not discussed the in-depth RMAN technology and have not told you how to write backup scripts. This is not my original intention. I just want to write what I will and learn with you, make progress together. Thank you.

1. Switch the server archive mode. skip this step if the archive mode is already used:
% Sqlplus/nolog (start sqlplus)
SQL> conn/as sysdba (connect to the database as DBA)
SQL> shutdown immediate; (close the database immediately)
SQL> startup mount (start the instance and load the database, but do not open it)
SQL> alter database archivelog; (change the database to archive Mode)
SQL> alter database open; (open the database)
SQL> alter system archive log start; (enable automatic archiving)
SQL> exit (exit)

2. Connection:
% Rman target = rman/rman @ mydb (start recovery Manager)

3. Basic settings:
RMAN> configure default device type to disk; (set the default backup device to disk)
RMAN> configure device type disk parallelism 2; (sets the parallel backup level and number of channels)
RMAN> configure channel 1 device type disk fromat '/backup1/backup _ % U'; (sets the backup file format, only applicable to disk devices)
RMAN> configure channel 2 device type disk fromat '/backup2/backup _ % U'; (sets the backup file format, only applicable to disk devices)
RMAN> configure controlfile autobackup on; (enable automatic backup of control file and server parameter file)
RMAN> configure controlfile autobackup format for device type disk to '/backup1/ctl _ % F'; (sets the file format for automatic backup of control files and server parameter files)

4. view all settings:
RMAN> show all

5. view the database solution report:
RMAN> report schema;

6. Full backup:
RMAN> backup database plus archivelog delete input; (back up full-database and control files, server parameter files, and all archived redo logs, and delete old archive logs)

7. Backup tablespace:
RMAN> backup tablespace system plus archivelog delete input; (backup the specified tablespace and archived redo logs, and delete the old archived logs)

8. Back up archived logs:
RMAN> backup archivelog all delete input;

9. Copy data files:
RMAN> copy datafile 1 to '/oracle/dbs/system. copy ';

10. View backups and duplicate files:
RMAN> list backup;

11. Verify the backup:
RMAN> validate backupset 3;

12. Restore the server parameter file from automatic backup:
RMAN> shutdown immediate; (close the database immediately)
RMAN> startup nomount; (start the instance)
RMAN> restore spfile to pfile '/backup1/mydb. ora' from autobackup; (recover the server parameter file from automatic backup)

13. Restore control files from automatic backup:
RMAN> shutdown immediate; (close the database immediately)
RMAN> startup nomount; (start the instance)
RMAN> restore controlfile to '/backup1' from autobackup; (restore control files from automatic backup)

13. Restore and restore the entire database:
RMAN> shutdown immediate; (close the database immediately)
RMAN> exit (exit)
% Mv/oracle/dbs/tbs_12.f/oracle/dbs/tbs_12.bak (rename the data file)
% Mv/oracle/dbs/tbs_13.f/oracle/dbs/tbs_13.bak (rename the data file)
% Mv/oracle/dbs/tbs_14.f/oracle/dbs/tbs_14.bak (rename the data file)
% Mv/oracle/dbs/tbs_15.f/oracle/dbs/tbs_15.bak (rename the data file)
% Rman target = rman/rman @ mydb (start recovery Manager)
RMAN> startup pfile =/oracle/admin/mydb/pfile/initmydb. ora (specify the initialization parameter file to start the database)
RMAN> restore database; (restore database)
RMAN> recover database; (Restore database)
RMAN> alter database open; (open the database)

14. Restore and restore tablespaces:
RMAN> SQL 'alter tablespace users offline immediate'; (take the tablespace offline)
RMAN> exit (exit recovery Manager)
% Mv/oracle/dbs/users01.dbf/oracle/dbs/users01.bak (rename the tablespace)
% Rman target = rman/rman @ mydb (start recovery Manager)
RMAN> restore tablespace users; (restore tablespace)
RMAN> recover tablespace users; (Restore tablespace)
RMAN> SQL 'alter tablespace users online'; (bring the tablespace online)

15. Incremental backup and recovery:
Incremental basic backup on the first day:
RMAN> backup incremental level = 0 database plus archivelog delete input;
Incremental differential backup for the next day:
RMAN> backup incremental level = 2 database plus archivelog delete input;
Incremental differential backup on the third day:
RMAN> backup incremental level = 2 database plus archivelog delete input;
Incremental differential backup on the fourth day:
RMAN> backup incremental level = 1 database plus archivelog delete input;
Incremental differential backup on the fifth day:
RMAN> backup incremental level = 2 database plus archivelog delete input;
Incremental differential backup on the sixth day:
RMAN> backup incremental level = 2 database plus archivelog delete input;
Incremental differential backup on the seventh day:
RMAN> backup incremental level = 0 database plus archivelog delete input;

Incremental recovery:
RMAN> shutdown immediate;
RMAN> exit
% Mv/oracle/dbs/tbs_12.f/oracle/dbs/tbs_12.bak
% Mv/oracle/dbs/tbs_13.f/oracle/dbs/tbs_13.bak
% Mv/oracle/dbs/tbs_14.f/oracle/dbs/tbs_14.bak
% Mv/oracle/dbs/tbs_15.f/oracle/dbs/tbs_15.bak
% Rman target = rman/rman @ mydb
RMAN> startup pfile =/oracle/admin/mydb/pfile/initmydb. ora
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;

Author: "Rman full Backup Recovery"

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.