SQL Server database scheduled automatic backup

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.