Use SQL Server's extended stored procedure for Remote Backup and Recovery

Source: Internet
Author: User
Recently, I am working on a data management module for the company's framework program (data application-oriented application system). The requirements for this module are relatively simple: backup, recovery, and log clearing. My company's software basically uses C/S as the basic architecture, so the two main features of the data management module 'backup and restore' may be operated on the Client side, backup and Recovery files may also be stored on the client. Therefore, this data management module must be able to remotely back up and restore the database.
After explaining the premise of the article, let's talk about how to implement it. In fact, they are all very simple. I want to write a remote backup test instance.
Let's take a look at it, so we can clearly describe it!
Instance description:
Environment: win2k 2 2 K query analyzer
SQLSERVER service instance name: mainserver
Name of the database to be backed up: msdb
Local Machine name (Client): david
Local User: zf password 123
Local domain: domain
Folder for local backup: e: est
Step 1: create a shared folder
Call net share test = e: est in the program code (or in the CMD window).
Or use netmask to add this API.
Brief description:
Net share: a WINDOWS Internal Network command.
Purpose: create a local shared resource to display the shared resource information of the current computer.
Syntax: see net share /?
Step 2: establish a shared credit relationship
Master.. Xp_mongoshell 'net use davidest 123/user: domainzf'
Brief description:
1: xp_mongoshell: an extended stored procedure of SQLSERVER.
To execute the specified command string in the command line interpreter of the operating system,
And return any output in text lines.
Syntax: see SQLSERVER online help
2: net use: a WINDOWS Internal Network command.
Function: connects or disconnects a computer from a shared resource, or displays information about the computer.
Connection information. This command also controls persistent network connections.
Syntax: see net use /?
Step 3: Back up the database
Backup database msdb to disk = 'davidestmsdb. Bak'
This does not need to be explained. For more information about the syntax, see SQL server online help.
Step 4: delete shared folders
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.