Oracle DB 10g+ Backup and Restore

Here's the steps for backupa db schema, which just applies to oracle database.

Supposetheoslschemaisosl/welcome1,andtheORACLE_SID=orcl,then:

  • ExportSchema(backup)
    • First,createdirectoryexpdir

      SQL>CONNECTsystem/welcome1

      SQL>CREATEORREPLACEDIRECTORYexpdirAS'/home/oracle/exp_data';

      SQL>GRANTREAD,WRITEONDIRECTORYexpdirTOPUBLIC;

    • Thenuseexpdp

      $ORACLE_HOME/bin/expdposl/welcome1@orclDUMPFILE=osl_bak.dmpDIRECTORY=expdirSCHEMAS=osl

    • Thenyoucancopythe/home/oracle/exp_data/osl_bak.dmptosomeotherdirectoryorsomeothermachinetobackupit.
  • ImportSchema(restore)
    • First,createdirectoryexpdir(ifyoualreadycreatedit,plzignorethisstep)
    • Thendeletetheoslschema(bewareofthisstep!!!)

      SQL>CONNECTsystem/welcome1

      SQL>DROPUSERoslCASCADE;

    • Thenuseimpdp

      $ORACLE_HOME/bin/impdposl/welcome1DIRECTORY=expdirDUMPFILE=osl_bak.dmp

相关推荐