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'