SQL Server还原选项
SQL Server还原选项:
     --创建备份设备
--创建备份设备
 sp_addumpdevice 'disk',jasonbak ,'C:\jason.bak'
sp_addumpdevice 'disk',jasonbak ,'C:\jason.bak'
 --备份
--备份
 backup database northwind to jasonbak
backup database northwind to jasonbak 
 with noinit--(附加,不加参数时默认)
with noinit--(附加,不加参数时默认)
 with init--(重写备份设备的内容)
with init--(重写备份设备的内容)
 with format--(重新格式化备份设备,使用)
with format--(重新格式化备份设备,使用)

 --还原
--还原
 restore filelistonly from jasonbak
restore filelistonly from jasonbak
 --查看文件列表(只能看到第一个备份内容)
--查看文件列表(只能看到第一个备份内容)
 restore headeronly from a]
restore headeronly from a]
 --查看设备内内容
--查看设备内内容
 restore verifyonly from a
restore verifyonly from a
 --校验
--校验

 
  
    
    
 restore database pubs from jasonbak
restore database pubs from jasonbak 
 restore database northwind from jasonbak with file=2
restore database northwind from jasonbak with file=2

 restore database northwind from jasonbak with norecovery
restore database northwind from jasonbak with norecovery
 restore log northwind from jasonbak with file=2
restore log northwind from jasonbak with file=2 


 --Changed to Simple修改恢复模型后一定要完全备份数据库
--Changed to Simple修改恢复模型后一定要完全备份数据库
 backup database northwind to jasonbak with format
backup database northwind to jasonbak with format
 --change back to Full
--change back to Full
 create table jason2 (Idd int)
create table jason2 (Idd int)
 backup log northwind to jasonbak
backup log northwind to jasonbak 
 restore verifyonly from jasonbak
restore verifyonly from jasonbak
 drop database northwind
drop database northwind

 restore database northwind from jasonbak with norecovery
restore database northwind from jasonbak with norecovery
 restore log northwind from jasonbak with file=2
restore log northwind from jasonbak with file=2

 --Full Backup nw
--Full Backup nw
 --Create Table1  ,write down the time
--Create Table1  ,write down the time
 --Create Table2  ,write down the time
--Create Table2  ,write down the time
 --Backup Log
--Backup Log 
 --Drop nw
--Drop nw
 --Recover Nw
--Recover Nw
 --Recover Table1, No table2
--Recover Table1, No table2

 backup database northwind to jasonbak with format
backup database northwind to jasonbak with format
 Create table table1 (IDD int)    --21.13.26
Create table table1 (IDD int)    --21.13.26
 Create table table2 (IDD int)    --21.13.35
Create table table2 (IDD int)    --21.13.35
 backup log northwind to jasonbak
backup log northwind to jasonbak
 restore northwind from jasonbak with stopat=""
restore northwind from jasonbak with stopat="" 
    
 --创建备份设备
--创建备份设备 sp_addumpdevice 'disk',jasonbak ,'C:\jason.bak'
sp_addumpdevice 'disk',jasonbak ,'C:\jason.bak' --备份
--备份 backup database northwind to jasonbak
backup database northwind to jasonbak  with noinit--(附加,不加参数时默认)
with noinit--(附加,不加参数时默认) with init--(重写备份设备的内容)
with init--(重写备份设备的内容) with format--(重新格式化备份设备,使用)
with format--(重新格式化备份设备,使用)
 --还原
--还原 restore filelistonly from jasonbak
restore filelistonly from jasonbak --查看文件列表(只能看到第一个备份内容)
--查看文件列表(只能看到第一个备份内容) restore headeronly from a]
restore headeronly from a] --查看设备内内容
--查看设备内内容 restore verifyonly from a
restore verifyonly from a --校验
--校验
 
  
    
 restore database pubs from jasonbak
restore database pubs from jasonbak  restore database northwind from jasonbak with file=2
restore database northwind from jasonbak with file=2
 restore database northwind from jasonbak with norecovery
restore database northwind from jasonbak with norecovery restore log northwind from jasonbak with file=2
restore log northwind from jasonbak with file=2 

 --Changed to Simple修改恢复模型后一定要完全备份数据库
--Changed to Simple修改恢复模型后一定要完全备份数据库 backup database northwind to jasonbak with format
backup database northwind to jasonbak with format --change back to Full
--change back to Full create table jason2 (Idd int)
create table jason2 (Idd int) backup log northwind to jasonbak
backup log northwind to jasonbak  restore verifyonly from jasonbak
restore verifyonly from jasonbak drop database northwind
drop database northwind
 restore database northwind from jasonbak with norecovery
restore database northwind from jasonbak with norecovery restore log northwind from jasonbak with file=2
restore log northwind from jasonbak with file=2
 --Full Backup nw
--Full Backup nw --Create Table1  ,write down the time
--Create Table1  ,write down the time --Create Table2  ,write down the time
--Create Table2  ,write down the time --Backup Log
--Backup Log  --Drop nw
--Drop nw --Recover Nw
--Recover Nw --Recover Table1, No table2
--Recover Table1, No table2
 backup database northwind to jasonbak with format
backup database northwind to jasonbak with format Create table table1 (IDD int)    --21.13.26
Create table table1 (IDD int)    --21.13.26 Create table table2 (IDD int)    --21.13.35
Create table table2 (IDD int)    --21.13.35 backup log northwind to jasonbak
backup log northwind to jasonbak restore northwind from jasonbak with stopat=""
restore northwind from jasonbak with stopat="" 
     
                    
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号