DBAtlas · Database operations atlas

Restore from backup

Oracle

impdp system/password DIRECTORY=dpump_dir \
  SCHEMAS=hr DUMPFILE=hr_%U.dmp LOGFILE=hr_imp.log

Use REMAP_SCHEMA to load into a different schema and REMAP_TABLESPACE for a different tablespace.

PostgreSQL

# custom format:
pg_restore -U postgres -d target_db --clean --if-exists db.dump
# plain SQL: psql -U postgres -d target_db -f db.sql

--clean drops existing objects. Use -j <n> for a parallel restore.

MySQL

mysql -u root -p target_db < db.sql

The target database must already exist (CREATE DATABASE). For large files the source command is preferred.

SQL Server

RESTORE DATABASE [MyDB]
FROM DISK = N'C:\backup\MyDB_full.bak'
WITH REPLACE, RECOVERY;

For point-in-time, restore the full backup WITH NORECOVERY, then apply log backups with STOPAT.

MongoDB

mongorestore --uri="mongodb://localhost:27017" \
  --archive=db.archive.gz --gzip --drop

--drop deletes the target collections before restoring. Use --nsInclude for a selective restore.

Redis

# 1) Stop Redis   2) Copy dump.rdb to the 'dir' location
# 3) Start Redis (the RDB is loaded automatically at startup)
redis-cli CONFIG GET dir   # find the target directory

With AOF enabled, the AOF is loaded instead of the RDB; to restore from the RDB, start with appendonly no or rebuild the AOF.

Open in DBAtlas →