sqlserver备份和恢复-5

视图备份和恢复

备份

1.

2.

恢复

1.

 

2.

3.勾选覆盖现有数据库。

4.

 

bat备份恢复

原文:

https://www.cnblogs.com/lonelyxmas/p/7958649.html

备份:(注意*.sql要写绝对路径不然计划任务不执行)

sqlserverbackup.bat
--------------------------------------
@echo off
set path=%path%;D:\Program Files\Microsoft SQL Server\100\Tools\Binn
set BakDir='D:\backup\sqlserver'
echo backup start
osql.exe -S 127.0.0.1 -U sa -P xxxxxx -i Test_ReportV3backup.sql -o D:\backup\sqlserver\Test_ReportV3backup.out
osql.exe -S 127.0.0.1 -U sa -P xxxxxx -i West_Report(Bata)backup.sql -o D:\backup\sqlserver\West_Report(Bata)backup.out
osql.exe -S 127.0.0.1 -U sa -P xxxxxx -i West_TestReportbackup.sql -o D:\backup\sqlserver\West_TestReportbackup.out
forfiles /p %BakDir% /s /m *.* /d -10 /c "cmd /c del @file"
echo backup end
---------------------------------------

*.sql
---------------------------------------
DECLARE @name varchar(50)
DECLARE @datetime char(14)
DECLARE @path varchar(255)
DECLARE @bakfile varchar(255)

set @datetime=CONVERT(char(8),getdate(),112) + REPLACE(CONVERT(char(8),getdate(),108),':','')
set @path='D:\backup\sqlserver\'
set @name='Test_ReportV3'
set @bakfile=@path+''+@name+'_'+'bak_'+@datetime+'.BAK'
backup database @name to disk=@bakfile with name=@name
go
---------------------------------------

 恢复

请看原文

posted @ 2018-09-01 17:31  xgmxm  阅读(4528)  评论(0编辑  收藏  举报