sql server数据库与日志文件备份sql语句

发布时间:2020-08-27编辑:脚本学堂
收集了一些sql server数据库文件备份、sql日志文件备份的语句,包括完全备份、差异备份、日志文件备份的sql语句等,需要的朋友参考下。

sql数据库备份与日志文件备份,常用sql语句
 

复制代码 代码示例:
--完全备份
backup database demo
to nwdevice02
with name = 'fullbak'
--日志备份
backup log demo
to nwdevice02
with name = 'log1'
--restore full backup
restore database demo
from nwdevice02
with file=1,norecovery
--restore log backup
restore log demo
from nwdevice02
with file=4,recovery
 
--完全备份
  backup database demo
  to nwdevice
  with name='完全备份'
--差异备份
  backup database demo
  to nwdevice
  with differential,
       name = '差异备份1'
 
--日志备份 log1
  backup log demo
  to nwdevice
  with name='日志1'
--日志备份 log2
  backup log demo
  to nwdevice
  with name='日志2'
--还原完全备份
  restore database demo
  from nwdevice
  with norecovery  --相当于第二项(选项)
       file = 1
--还原差异
  restore database demo
  from nwdevice
  with recovery,
       file= 2
 /* 第一完全备,第二次差异备份*/
--还原日志
  restore log demo
  from nwdevice
  with file= 2,
       norecovery
restore log demo
from nwdevice
with file= 3,
recovery