SQL Server Remote Backup, recovery (RPM)

Source: Internet
Author: User

SQL Server Service Instance name: 192.168.0.2
Name of database to be backed up: a
Backup machine name (client side): 192.168.0.3
Backup machine User: ZF Password: 123
Backup machine domain name: domain
folder where the backup machine provides backup requirements: D:\sqlbak

Backing Up the database

First step: Create a shared folder on the backup machine
Call in program code (or CMD window) net share Sqlbakup=d:\sqlbak or use Netshareadd this API
Brief description:
NET share: is a network command inside windows.
Role: Establish a local shared resource that displays the shared resource information for the current computer.

Step two: Establish a shared credit relationship
EXEC master. xp_cmdshell ' net use File://192.168.0.3/sqlbak 123/user:domain\zf '
Brief description:
1:xp_cmdshell: is an extended stored procedure for SQL Server.
Function: Executes the given command string as an operating system command-line interpreter and returns any output as a text line.
Syntax: See SQL Server online Help
2:net use: is a network command inside windows.
Function: Connect or disconnect a computer from a shared resource, or display information about a computer connection.

This command also controls persistent network connections.

Step three: 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)

Fourth step: Delete the shared folder
Call in program code (or CMD window) net share Sqlbakup/delete
Or use the Netsharedel API

Recovering a Database

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

The following is a differential restore
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 '

SQL Server Remote Backup, recovery (RPM)

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.