SQL Server Database scheduled automatic backup-daily scheduled backups, 8 days of backup retention
Use SQL Server Agent new job to back up regularly
1) in the database Library "SQL Server Agent", "Jobs", right-click "New Job"
2) On the General tab, set the name (custom)
3) Tap New on the Steps tab, then set the step name (custom) in the General tab of the Pop-up window, choose Type as Transact-SQL script (T-SQL), select database for the database you want to back up, add the following command, Then click "Analyze" to see if the command is successful.
EXECsp_configure'Show advanced Options',1 Reconfigure withOVERRIDEEXECsp_configure'xp_cmdshell',1 Reconfigure withOVERRIDEDECLARE @DelStr nvarchar( -)SET @DelStr='Del D:\WebSiteBack\TMSoftwareTest_DbBack\TMSoftwareTest'+left(REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(Ten),GETDATE()-8, -),' ',"'),':',"'),'-',"'),'.',"'),8)+ '*.bak' EXECxp_cmdshell@DelStr DECLARE @fileName nvarchar( -) SET @fileName='D:\WebSiteBack\TMSoftwareTest_DbBack\TMSoftwareTest'+REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(Ten),GETDATE(), -),' ',"'),':',"'),'-',"'),'.',"')+ '. bak' BACKUP DATABASE [tmsoftwaretest] to DISK = @fileName withNoinit, Nounload, NAME=N'tmsoftwaretest Backup', Noskip, STATS= Ten, Noformat
Instructions (daily scheduled backups, 8 days of backup Records):
4) Click "New" in the "Schedule" tab and set the parameters in the popup window as follows:
5) Click "OK" to find the newly created job below.
① first ensure that the SQL Server Agent service Proxy in Configuration Manager is turned on (start, All programs, locate your SQL folder under Configuration Tools, SQL Server Configuration Manager, SQL Server 2005 Service "(My Own is SQL2005)," SQL Server Agent (B) "Check right-click Start);
② Select SQL Server Agent, right-click Start
③ Select the job you just created, right-click Start Job
Other references: http://www.cnblogs.com/zhangq723/archive/2012/03/13/2394102.html
SQL Server database scheduled automatic backup