[Switch] Oracle9i RMAN backup and recovery steps
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 the database)
RMAN> recover database; (recover the database)
RMAN> alter database open; (Open Database)
14. Restore and restore tablespaces:
RMAN> SQL 'alter tablespace users offline immediate'; (remove 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 '; (bringing tablespaces 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 on 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;