数据库的备份与恢复
1、SQL Server
备份
SQL语句添加计划任务
BACKUP DATABASE [ProjectBUGReport] TO DISK = N'D:\db_back\ProjectBUGReport.bak' WITH NOFORMAT, NOINIT, NAME = N'ProjectBUGReport', SKIP, REWIND, NOUNLOAD, STATS = 10
维护计划添加备份数据库任务
恢复
直接在管理工具里面使用bak备份文件进行恢复
2、Mysql
备份
添加BAT处理文件
@echo off
C:
set "Ymd=%date:,4%%date:5,2%%date:~8,2%"
cd C:\Program Files\MySQL\MySQL Server 5.5\bin
mysqldump -h127.0.0.1 -P3306 -uroot --password=sb2012 db_simp > D:\db_backup\db_simp_%Ymd%.sql
@echo on
Mysql 5.6版本需在my.cnf配置文件中的mysqldump下添加
User=root password=xxxx
恢复
mysql -u root –password=root密码 数据库名 < 备份文件.sql
3、MongoDB
整库备份:sudo mongodump -h 1.1.1:9999 -d jyCensus -o /var/dbBack -u sunbird -p 123456 --authenticationDatabase admin
整库恢复:sudo mongorestore -h 1.1.1.1:9999 -u xxx -p xxx -d jyCensus /var/dbBack --authenticationDatabase admin
4、Oracle
备份:exp NEWSPAPER/NEWSPAPER@SBNEW file=d:\dbback\NEWSPAPER.dmp owner=NEWSPAPER
恢复:imp NEWSPAPER/NEWSPAPER@SBNEW file=d:\dbback\NEWSPAPER.dmp FULL=Y