Four automatic backup methods for mssqlserver Databases

Source: Internet
Author: User
Tags mssqlserver management studio sql server management studio
This article collects four methods for automatic backup of the mssqlserver database. We use the job method and the maintenance plan method for automatic backup. If you need it, you can refer to them.

This article collects four methods for automatic backup of the mssqlserver database. We use the job method and the maintenance plan method for automatic backup. If you need it, you can refer to them.

Method 1: Job

Specific steps for automatic backup in SQL Server 2005:

1. Open SQL Server Management Studio

2. Start the SQL Server proxy

3. Click job> create job.

4. Enter the job name in "regular"

5. Create step, type select T-SQL, enter the following statement in the following command

The Code is as follows:

DECLARE @ strPath NVARCHAR (200)

Set @ strPath = convert (NVARCHAR (19), getdate (), 120)

Set @ strPath = REPLACE (@ strPath ,':','.')

Set @ strPath = 'f: Bak' + 'hpxx' + @ strPath + '. Bak'

Backup database [hpxx] to disk = @ strPath with noinit, NOUNLOAD, NOSKIP, STATS = 10, NOFORMAT

(D: Change the bak to your backup path, and change databasename to the name of the database you want to back up)

6. Add a plan and set the frequency and time.

OK.


Method 2:
SQL SERVER 2005 automatic backup maintenance plan
In SQL Server 2005, you can use maintenance plans to automatically back up databases, reducing the workload of database administrators. The usage is as follows:

(1) start SQL server Management Studio and select Manage> maintenance plan in the object Resource Manager window.

2) Right-click maintenance plan and choose maintenance plan wizard from the shortcut menu.

In the displayed maintenance plan wizard dialog box, click Next.

3) The select target server dialog box is displayed. In the Name text box, enter the name of the maintenance plan. In the description text box, enter the description of the maintenance plan; in the server text box, enter the name of the server you want to use. Finally, select the correct ID card and click Next.

(4) The select maintenance task dialog box is displayed.

You can select a variety of maintenance tasks: Check database integrity, shrink the database, regenerate or organize indexes, update statistics, clear historical records, and execute SQL

Server proxy job, backup database, etc. In this example, select the backup database (complete) Check box. The settings for other maintenance tasks are similar.

(5) Click Next to bring up the select maintenance task sequence dialog box. If there are multiple maintenance tasks, you can click the move up and move down buttons to set the order of maintenance tasks. After the settings are complete, click Next.

(6) The define task dialog box is displayed, under database.

Select the name of the database to be backed up from the drop-down list box. In the backup components area, select backup database or backup database file; in the [target] area, you can add Backup files and devices, and set whether to append backup data to the backup files. Click Next after setting.

(7) The select plan attribute dialog box is displayed, and click Change.

8) the create job plan dialog box is displayed. In this dialog box, you can set the time and frequency of backing up the database. After setting, click OK to return to the following dialog box, click Next.

(9) The "Select Report option" dialog box shown in 18.24 is displayed. In this dialog box, you can choose to manage the maintenance plan report, which can be written to a file, you can also email the database administrator. Click Next after setting.

10) in the complete wizard dialog box, click Finish to create the maintenance plan.

11) after creating the maintenance plan, check whether the SQL server proxy is started. In the object Resource Manager window, right-click SQL

Server proxy, and select start in the shortcut menu that appears.

If the backup fails, check whether the SQL Server2005 intergration Services Service is not installed. You must first import the job.

Method 3


The creation process is as follows:

A. open SQL Server Management Studio, connect to your instance, and open "Object Resource Manager, press F8 to expand the instance -- manage -- maintenance plan -- Right-click "Maintenance Plan" -- create maintenance plan -- enter the maintenance plan name -- the window for creating the maintenance plan will appear.

B. In the left Toolbox (if not, press Ctrl + Alt + X), drag the "backup database task" to the yellow area in the middle.

C. double-click this task to display the design attribute window. in the database, select the database you want to back up, set the backup to there, and set the backup file name, after the design, click "OK", you can also click "T-SQL" to see what statements SQL will roughly use to deal with your needs.

D. Click the "..." button after "plan" to set the execution time plan.


Method 4

1. Create a job
2. Add General
3. Add step, select T-SQL enter the following statement (databasename change to your own database name. D: bak change to your own backup path)

The Code is as follows:
DECLARE @ strPath NVARCHAR (200)
Set @ strPath = convert (NVARCHAR (19), getdate (), 120)
Set @ strPath = REPLACE (@ strPath ,':','.')
Set @ strPath = 'd: bak '+ @ strPath +'. Bak'
Backup database [databasename] to disk = @ strPath with noinit, NOUNLOAD, NOSKIP, STATS = 10, NOFORMAT

4. Add a plan and set the frequency and time.
5. Remember to enable the SQL Server Agent service

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.