从备份恢复
Oracle
impdp system/password DIRECTORY=dpump_dir \
SCHEMAS=hr DUMPFILE=hr_%U.dmp LOGFILE=hr_imp.log加载到其他 schema 使用 REMAP_SCHEMA,加载到其他表空间使用 REMAP_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 会删除现有对象。并行恢复使用 -j <n>。
MySQL
mysql -u root -p target_db < db.sql目标数据库必须已存在(CREATE DATABASE)。对于大文件,推荐使用 source 命令。
SQL Server
RESTORE DATABASE [MyDB]
FROM DISK = N'C:\backup\MyDB_full.bak'
WITH REPLACE, RECOVERY;时间点恢复时,先 WITH NORECOVERY 恢复完整备份,再用 STOPAT 应用日志备份。
MongoDB
mongorestore --uri="mongodb://localhost:27017" \
--archive=db.archive.gz --gzip --drop--drop 会在恢复前删除目标集合。选择性恢复使用 --nsInclude。
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启用 AOF 时,加载的是 AOF 而不是 RDB;要从 RDB 恢复,需以 appendonly no 启动或重建 AOF。