可以用備份作業:/*******************完整備份作業******************
*/--
完整備份,每週一次
usemaster
godeclare
@str
varchar(100
)set
@str='
d:\dbtext\jgj\dbabak\fullbak'+
replace(replace(replace(convert(varchar,getdate(),20),'
-',''),'
',''),'
:','')+
'.bak
'backup
database
[demo]to
disk
=@str
with retaindays=
15,noformat,noinit,
name
=n'demo完整備份
',skip,norewind,
nounload,stats=10
go/*
******************差異備份作業******************
*/--
截斷日誌
usemaster
gobackup
log demo with
no_log
go--
收縮日誌檔案
usedemo
godbcc shrinkfile (n'
demo_log
',0,truncateonly)
go--
差異備份,每天一次
usemaster
godeclare
@str
varchar(100
)set
@str='
d:\dbtext\jgj\dbabak\diffbak'+
replace(replace(replace(convert(varchar,getdate(),20),'
-',''),'
',''),'
:','')+
'.diff
'backup
database
[demo]to
disk
=@str
with differential,retaindays=
8,noformat,noinit,
name
=n'demo差異備份
',skip,norewind,
nounload,stats=10
go/*
*****************日誌備份作業******************
*/--
日誌備份,每小時一次
usedemo
godeclare
@str
varchar(100
)set
@str='
d:\dbtext\jgj\dbabak\logbak'+
replace(replace(replace(convert(varchar,getdate(),20),'
-',''),'
',''),'
:','')+
'.trn
'backup
log[
demo]to
disk
=@str
with retaindays=
3,noformat,noinit,
name
=n'demo日誌備份
',skip,norewind,
nounload,stats=10
go--
刪除過期的備份檔案,每天兩次
declare
@str
varchar(100),@dir
varchar(100),@filename
varchar(30
)set
@dir='
del d:\dbtext\jgj\dbabak\
'set
@filename
=left(replace(replace(replace(convert(varchar,getdate()-
15,20),'
-',''),'
',''),'
:',''),8
)set
@str
=@dir+'
fullbak'+
@filename+'
*.bak
'exec xp_cmdshell @str
set@filename
=left(replace(replace(replace(convert(varchar,getdate()-
8,20),'
-',''),'
',''),'
:',''),8
)set
@str
=@dir+'
diffbak'+
@filename+'
*.diff
'exec xp_cmdshell @str
set@filename
=left(replace(replace(replace(convert(varchar,getdate()-
8,20),'
-',''),'
',''),'
:',''),8
)set
@str
=@dir+'
logbak'+
@filename+'
*.trn
'exec xp_cmdshell @str
windows任務計畫執行sql指令碼備份資料庫
一 編寫sql指令碼 declare dbs table rownum intidentity 1,1 primary key,dbname nvarchar 200 bakpath as n e dbbackup dbname dbname replace replace replace conv...
oracle備份計畫
所有的指令碼勻在 dsk3 bk scripts中 oracle sia scripts cat connect.rcv 連線rman指令碼 connect target sys oracle prod oracle sia scripts cat del obso.rcv 刪除歸檔日誌狀態為exp...
SQL SERVER 備份計畫
master.xp cmdshell net use 1.1.1.1 資料備份 wonders,1 user 1.1.1.1 databackup 如果未開啟許可權,則使用 exec sp configure show advanced options 1 允許配置高階選項 配置選項 show ad...