>  기사  >  데이터 베이스  >  用于校验 SQL Server 数据库备份的脚本

用于校验 SQL Server 数据库备份的脚本

WBOY
WBOY원래의
2016-06-07 14:54:581119검색

你是否遇见过这样的情况,每天进行正常的数据库备份。但是当需要从备份中恢复数据库的时候却失败了?本脚本就是对备份进行校验,保证恢复的成功。 备份 SQL Server USE MASTER-- Add a new backup device-- Ensure that the SQL Server can read from the phy

你是否遇见过这样的情况,每天进行正常的数据库备份。但是当需要从备份中恢复数据库的时候却失败了?本脚本就是对备份进行校验,保证恢复的成功。 备份 SQL Server
USE MASTER
-- Add a new backup device
-- Ensure that the SQL Server can read from the physical location where the backup is placed
--                    TYPE      NAME		   PHYSICAL LOCATION
EXEC SP_ADDUMPDEVICE 'disk','networkdrive','\\VPCW2K8\Database Backup\Test.bak'

-- Execute the Restore operation in VERIFY ONLY mode
-- Provide the actual paths where you plan to restore the database.
-- This is because VERIFYONLY also checks for available space
RESTORE
VERIFYONLY
FROM  networkdrive
WITH
MOVE N'TESTDB_DATA'    TO N'E:\TestDB\TestDB_Data.mdf',  
MOVE N'TESTDB_INDEXES' TO N'E:\TestDB\TestDB_Idx.mdf',  
MOVE N'TESTDB_LOG'     TO N'E:\TestDB\TestDB_LOG.ldf'

-- DROP THE DEVICE
--                   Name         , Physical File (OPTIONAL - if present, the file is deleted)
EXEC SP_DROPDEVICE 'networkdrive'
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:MySQL 导出表到 XML 文件다음 기사:array to csv