SQL Server Remote backup and recovery

Source: Internet
Author: User

Sqlserver service instance name: 192.168.0.2
Name of the database to be backed up:
Backup Machine name (client): 192.168.0.3
Backup Machine User: ZF password: 123
Backup Machine Domain Name: domain
Folder for backup on the backup machine: D: \ sqlbak

Back up database

Step 1: create a shared folder on the backup machine
Call net share sqlbakup = D: \ sqlbak 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.

Step 2: Establish a shared credit relationship
Exec master.. xp_mongoshell 'net use file: // 192.168.0.3/sqlbak 123/User: domain \ ZF'
Brief description:
1: xp_mongoshell: an extended stored procedure of sqlserver.
Purpose: run the given command string in the command line interpreter of the operating system and return any output in the text line.
Syntax: see sqlserver online help
2: net use: A Windows internal network command.
Purpose: connect or disconnect a computer from a shared resource, or display information about the computer connection.

This command also controls persistent network connections.

Step 3: Back up the database
Backup database a to disk = '\ 192.168.0.3 \ sqlbak \ A. Bak'
Backup database a to disk = '\ 192.168.0.3 \ sqlbak \ a1.bak' with differential (differential backup)

Step 4: delete Shared Folders
Call net share sqlbakup/delete in the program code (or in the CMD window)
Or use the netdomaindel API.

Restore database

Restore database a from disk = '\ 192.168.0.3 \ sqlbak \ A. Bak'

Difference recovery
Restore database SCS from disk = '\ 192.168.0.3 \ sqlbak \ A. Bak' with norecovery
Restore database SCS from disk = '\ 192.168.0.3 \ sqlbak \ a1.bak' with norecovery
Restore database SCS from disk = '\ 192.168.0.3 \ sqlbak \ a2.bak'

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.