The Specific Method of oracle Backup Recovery

  • 2021-09-16 08:28:15
  • OfStack

1.1 Full database backup of database data
Note: This operation requires starting the database.

Switch to the oracle user and create the backup usage directory on the OS side:

mkdir /oracle/backup

Log in to the oracle database and create a backup usage directory in the database

sqlplus / as sysdba

create directory backupdir as '/oracle/backup';

After exiting sqlplus, use oracle user to perform full library backup, and the backup file is generated under/oracle/backup:

expdp system/System123 DIRECTORY=backupdir DUMPFILE=backup201309XX.dmp logfile=backup.log full=y

1.2 Database Data Recovery

Note: This operation requires starting the database.

1. Log in to the database server with orale user

2. Delete the user to be restored.

sqlplus / as sysdba

drop user USER_NAME cascade;

exit

3. Execute the recovery command

The following statement restores the data of the pgm user to the backup201309XX. dmp state

impdp system/System123 DIRECTORY=backupdir DUMPFILE=backup201309XX.dmp schemas=pgm TABLE_EXISTS_ACTION=TRUNCATE logfile=restore.log

Considerations when recovering a database:

The exp/imp method of backing up and restoring a database fails to delete and modify database definitions (i.e. table structures and the like).

Therefore, if the database table structure changes during recovery, it is necessary to restore the table structure, or delete the table and then perform the recovery operation. If you don't know which table structure has changed, you can delete the database users that need to be restored before performing the recovery operation.

In addition, it has been proved that there is a problem in restoring the table after deleting it: when deleting the table, the foreign keys created by other tables referencing this table are deleted.

On recovery, the foreign key cannot be recovered. This situation requires manual creation of foreign key constraints after recovery.

drop table TABLE_NAME cascade constraints;

impdp system/System123 DIRECTORY=backupdir DUMPFILE=backup201309XX.dmp tables=sdu.E_UC_ENTANN TABLE_EXISTS_ACTION=TRUNCATE logfile=restore_sdu.log


Related articles: