您好,登錄后才能下訂單哦!
----------------------------------------------備份數據庫-----------------------------------------------------------------------
USE [master]
GO
ALTER DATABASE [TEST] SET RECOVERY SIMPLE WITH NO_WAIT --簡單
USE [TEST]
go
DBCC SHRINKFILE (N'Leader_Log' , 0, TRUNCATEONLY) --縮日志
USE [master]
GO
ALTER DATABASE [TEST] SET RECOVERY FULL WITH NO_WAIT --完整
declare
@RiQi varchar(6),
@LuJing varchar(200),
@Path varchar(200)
set @Path = '\\DC01\Buckups$\' --用鏡像賬號網絡共享存儲
set @RiQi = (select CONVERT(varchar(4),DATEPART(YEAR,getdate())) + CONVERT(varchar(2),DATEPART(mm,getdate())))
set @LuJing = @Path + @RiQi + 'TEST.bak'
backup database TEST to disk=@LuJing with init
declare
@RiQi varchar(6),
@LuJing varchar(200),
@Path varchar(200)
set @Path = '\\DC01\Buckups$\'
set @RiQi = (select CONVERT(varchar(4),DATEPART(YEAR,getdate())) + CONVERT(varchar(2),DATEPART(mm,getdate())))
set @LuJing = @Path + @RiQi + 'TEST.bak'
backup log TEST to disk=@LuJing
-----------------------------------------------查看備份文件--------------------------------------------------------------------------------------
restore headeronly from disk='\\DC01\Buckups$\20183TEST.bak'
-----------------------------------------------還原數據庫----------------------------------------------------------------------
restore database TEST from disk='\\DC01\Buckups$\TEST.bak' with file=1,replace,norecovery --第一個完整還原
restore log TEST from disk='\\DC01\Buckups$\20183TEST.bak' with file=2,replace,norecovery --第二個日志還原
restore log TEST from disk='\\DC01\Buckups$\20183TEST.bak' with file=3,replace,norecovery --第三個日志還原
restore log TEST from disk='\\DC01\Buckups$\20183TEST.bak' with file=4,replace,recovery --最后一個日志還原
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。