대상으로 import
Oracle
# Import with Data Pump; remap schema and tablespace
impdp system/password directory=DIR_DMP dumpfile=shop_%U.dmp \
logfile=shop_imp.log \
remap_schema=shop:shop_new \
remap_tablespace=USERS:DATA parallel=4
# For existing objects: TABLE_EXISTS_ACTION=TRUNCATE|APPEND|REPLACEimpdp는 expdp로 받은 .dmp 파일을 대상에 적재한다. REMAP_SCHEMA는 소스를 다른 스키마로, REMAP_TABLESPACE는 다른 테이블스페이스로 옮기며, 환경 간 마이그레이션에서 자주 사용된다. 기존 테이블에 대한 동작은 TABLE_EXISTS_ACTION으로, 속도는 PARALLEL로 지정한다.
PostgreSQL
# Parallel restore (from custom/directory format)
pg_restore -j4 -d targetdb --no-owner --clean --if-exists shop.dump
# A specific table only: pg_restore -d targetdb -t customer shop.dump
# For a plain .sql dump: psql -d targetdb -f shop.sqlpg_restore -j는 custom/directory 형식 덤프를 병렬(다중 프로세스)로 적재하며, 대형 데이터베이스에서 적재 속도를 크게 높인다. --clean --if-exists는 대상의 객체를 먼저 삭제하고, --no-owner는 다른 롤 구조에 맞춘다. 일반 SQL 덤프는 psql -f로 적재한다(병렬 아님).
MySQL
# Load a plain SQL dump
mysql --binary-mode shop < shop.sql
# Parallel/fast load (if taken with mydumper):
myloader --directory=./backup --database=shop --threads=4 --overwrite-tables
# Tip: SET FOREIGN_KEY_CHECKS=0; unique_checks=0 before loading speeds it up.mysqldump SQL 덤프는 mysql 클라이언트로 리다이렉트하여 적재한다(mysql shop < dump.sql). 병렬로 훨씬 빠르게 적재하려면 mydumper로 받은 디렉터리를 myloader --threads로 복원한다. 적재 중 FOREIGN_KEY_CHECKS와 UNIQUE_CHECKS를 비활성화하면 성능이 향상된다.
SQL Server
-- Restore from a physical backup (move file paths to the new environment)
RESTORE DATABASE shop FROM DISK = 'C:\backup\shop.bak'
WITH MOVE 'shop_data' TO 'D:\data\shop.mdf',
MOVE 'shop_log' TO 'D:\log\shop.ldf', REPLACE;
-- Import from a BACPAC (schema+data):
-- sqlpackage /Action:Import /TargetConnectionString:"..." /SourceFile:shop.bacpac.bak 백업은 RESTORE DATABASE로 적재한다. 다른 디스크 구성으로 옮길 때는 WITH MOVE로 데이터/로그 파일을 새 경로로 지정한다. 버전 독립/Azure SQL 대상에는 SqlPackage /Action:Import가 .bacpac 파일(스키마 + 데이터)을 새 데이터베이스로 생성한다.
MongoDB
# Restore the BSON backup; replay the oplog to land on a single point in time
mongorestore --uri="mongodb://target:27017" --oplogReplay \
--numParallelCollections=4 ./backup
# Renaming: --nsFrom='shop.*' --nsTo='shop_new.*'
# Drop existing data before loading: --dropmongorestore는 mongodump BSON 출력을 대상에 적재한다. --oplogReplay는 --oplog로 받은 백업의 oplog 변경을 재생해 덤프를 단일 일관된 시점으로 맞춘다. 데이터베이스/컬렉션 이름은 --nsFrom/--nsTo로 바꾸고, 기존 데이터는 --drop으로 지울 수 있다.
Redis
# Stop the server, place dump.rdb in the data directory, start it again
# 1) systemctl stop redis (or SHUTDOWN NOSAVE)
# 2) cp dump.rdb <path found with CONFIG GET dir>/dump.rdb
# 3) systemctl start redis -> Redis loads the RDB into memory at startup
# Alternative (live): feed a RESP command stream with redis-cli --pipeRedis는 시작 시에만 RDB를 적재한다. 따라서 대상 서버를 중지하고, 옮겨 온 dump.rdb를 데이터 디렉터리(CONFIG GET dir)에 둔 뒤 서버를 재시작한다. 시작 시 RDB에서 메모리가 채워진다. 서버를 중지하지 않고 적재하려면 redis-cli --pipe로 RESP 형식의 키를 스트리밍한다.
Elasticsearch
# Register the same repository on the target cluster, then restore the snapshot
PUT _snapshot/migration_repo
{ "type": "fs", "settings": { "location": "/mnt/es_backup" } }
POST _snapshot/migration_repo/migration_1/_restore
{ "indices": "customer,orders",
"rename_pattern": "(.+)", "rename_replacement": "restored_$1" }대상 클러스터에 소스와 같은 스냅샷 리포지토리를 등록한 뒤(파일에 접근 가능해야 함) _snapshot/.../_restore로 인덱스를 복원한다. 인덱스 이름은 rename_pattern/rename_replacement로 바꿀 수 있다. 기존 인덱스는 열린 상태에서 복원할 수 없으므로 먼저 닫거나 이름을 바꾼다.