任意のバックアップから復元する

Oracle impdpコマンドを使用して、バックアップ先のディレクトリオブジェクト上のバックアップから復元を実行します。

以下は、expdpで取得したバックアップからimpdpを使用して復元を行う操作例です。expdpに関しては「任意のバックアップを実行する」を参考にしてください。

接続ユーザーtest_user
パスワード#######
接続文字列ORCL
対象スキーマtest_user
ディレクトリオブジェクトtest_dir
ダンプファイルbackup.dmp
データが存在する場合の処理truncate
$ expdp userid=testusr1/########@ORCL directory=test_dir dumpfile=exp.dmp
$ impdp userid=test_user/########@ORCL directory=test_dir schemas=test_user table_exists_action=truncate dumpfile=exp.dmp

Import: Release 19.0.0.0.0 - Production on Thu Jan 23 13:14:45 2025
Version 19.25.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Master table "TEST_USER"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "TEST_USER"."SYS_IMPORT_SCHEMA_01":  userid=test_user/********@ORCL directory=test_dir schemas=test_user table_exists_action=truncate dumpfile=exp.dmp
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"TEST_USER" already exists

Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Table "TEST_USER"."TEST_TABLE" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TEST_USER"."TEST_TABLE"                      5.5 KB       1 rows
・
<省略>
・
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "TEST_USER"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at Thu Jan 23 13:14:52 2025 elapsed 0 00:00:06