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)