Home Database Mysql Tutorial SQL Server扩展存储过程实现远程备份与恢复

SQL Server扩展存储过程实现远程备份与恢复

Jun 07, 2016 pm 03:05 PM
server sql backup storage accomplish Expand process Remotely

本文通过实例解析了 SQL Server 数据库 扩展 存储 过程 , 实现 远程 备份 与 恢复 的方法和步骤…… 实例说明: 环境:win2k+sqlserver 2K+查询分析器 SQL SERVER服务实例名称:mainserver 需要 备份 的数据库名称: msdb 本地机器名称(Client端):david 本地

  本文通过实例解析了 SQL Server 数据库扩展存储过程实现远程备份恢复的方法和步骤……

  实例说明:

  1.   环境:win2k+sqlserver 2K+查询分析器
  2.   SQL SERVER服务实例名称:mainserver
  3.   需要备份的数据库名称: msdb
  4.   本地机器名称(Client端):david
  5.   本地用户:zf 密码:123
  6.   本地域名:domain
  7.   本地提供备份需求的文件夹:e: est

  第一步: 建立共享文件夹

  在程序代码中调用(或者CMD窗口) net share test=e: est

  或者用NetShareAdd这个API

  简要说明:

  net share: 是WINDOWS内部的网络命令。

  作用:建立本地的共享资源,显示当前计算机的共享资源信息。

  语法:参见 net share /?

  第二步: 建立共享信用关系

  master..xp_cmdshell 'net use \david est 123 /user:domainzf'

  简要说明:

  1:xp_cmdshell :是SQLSERVER的扩展存储过程

  作用,以操作系统命令行解释器的方式执行给定的命令字符串,

  并以文本行方式返回任何输出。

  语法:参见SQLSERVER联机帮助

  2:net use: 是WINDOWS内部的网络命令。

  作用,将计算机与共享资源连接或断开,或者显示关于计算机

  连接的信息。该命令还控制持久网络连接。

  语法:参见 net use /?

  第三步:备份数据库

  backup database msdb to disk='\david estmsdb.bak'

  这个不需要说明吧,语法参见SQLSERVER联机帮助

  第四步: 删除共享文件夹

  在程序代码中调用(或者CMD窗口) net share test /delete

  或者用NetShareDel这个API

  结果:

  已处理 1376 页,这些页属于数据库 'msdb' 的文件 'MSDBData'(位于文件 1 上)。

  已处理 1 页,这些页属于数据库 'msdb' 的文件 'MSDBLog'(位于文件 1 上)。

  BACKUP DATABASE 操作成功地处理了 1377 页,花费了 3.653 秒(3.086 MB/秒)。

  这样mainserver服务器上的msdb就备份到了david机器的E: estmsdb.bak文件了,使用起来很简单吧?恢复数据库操作也是一样,只要将第三个步骤的语句改为'restore database msdb from disk='\david estmsdb.bak'就可以啦。。你看完了也可以试试呀?!(最简单的测试工具查询分析器+CMD窗口)

  备注:xp_cmdshell 这个扩展存储过程只能SA级别的用户调用,而且是SQL Server的安全隐患之一,许多DBA都喜欢将其删除或者禁用,所以开发人员使用时要倍加小心哦。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

How to implement dual WeChat login on Huawei mobile phones? How to implement dual WeChat login on Huawei mobile phones? Mar 24, 2024 am 11:27 AM

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Mar 07, 2024 pm 10:43 PM

This website reported on March 7 that Dr. Zhou Yuefeng, President of Huawei's Data Storage Product Line, recently attended the MWC2024 conference and specifically demonstrated the new generation OceanStorArctic magnetoelectric storage solution designed for warm data (WarmData) and cold data (ColdData). Zhou Yuefeng, President of Huawei's data storage product line, released a series of innovative solutions. Image source: Huawei's official press release attached to this site is as follows: The cost of this solution is 20% lower than that of magnetic tape, and its power consumption is 90% lower than that of hard disks. According to foreign technology media blocksandfiles, a Huawei spokesperson also revealed information about the magnetoelectric storage solution: Huawei's magnetoelectronic disk (MED) is a major innovation in magnetic storage media. First generation ME

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

Extensions and third-party modules for PHP functions Extensions and third-party modules for PHP functions Apr 13, 2024 pm 02:12 PM

To extend PHP function functionality, you can use extensions and third-party modules. Extensions provide additional functions and classes that can be installed and enabled through the pecl package manager. Third-party modules provide specific functionality and can be installed through the Composer package manager. Practical examples include using extensions to parse complex JSON data and using modules to validate data.

See all articles