Database automatic backup (SLQ Server agent job) __ Database

Source: Internet
Author: User

The main tasks to be accomplished are:

1. Periodic (periodic) backups of the database

2. Perform certain actions (work) at regular intervals

For example: The job that needs to be done is to test the database 1:00 every day, backup a copy of D:\fullbak, and name the backup database Test+yyymmdd (back up time). bak.

--Database automatic backup (SQL Server Agent-> job-> right key new job-> general inside write name and owner-> step inside code-> plan inside write frequency and execution time)

First step: In the SQL Server agent, select the job, right-click the new job, and fill in the job name. Description: Function Description of this job



Step Two: Click the step, create a new one, in the 3rd position shown in the following figure, you edit the code for the backup database:

DECLARE @filename VARCHAR (255)
DECLARE @date DATETIME
SELECT @date =getdate ()
SELECT @filename = ' F:\fullbak\test '
+cast (DATEPART (yyyy, @date) as varchar)
+cast (DATEPART (mm, @date) as varchar)
+cast (DATEPART (DD, @date) as varchar) + '. Bak '
BACKUP DATABASE [Test] to DISK = @filename with COMPRESSION


Step three: In the click Plan, new plan. Set the execution frequency in the plan






Conclusion: This database can be based on your own set up the cycle, automatic backup database. Once the database has been accidentally deleted, you can use the Backed-up database to restore it.



PS: I hope this agent work for everyone to help.



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.