backup/restore database

backup database t-sql

1 BACKUP DATABASE [store] TO  DISK = N‘D:\sql_back\store_backup_2019_01_30_102306_4000360.bak‘ WITH NOFORMAT, NOINIT,  NAME = N‘store_backup_2019_01_30_102306_4000360‘, SKIP, REWIND, NOUNLOAD,  STATS = 10
2 GO
3 declare @backupSetId as int
4 select @backupSetId = position from msdb..backupset where database_name=N‘store‘ and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N‘store‘ )
5 if @backupSetId is null begin raiserror(N‘验证失败。找不到数据库“store”的备份信息。‘, 16, 1) end
6 RESTORE VERIFYONLY FROM  DISK = N‘D:\sql_back\store_backup_2019_01_30_102306_4000360.bak‘ WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND

restore database

1 USE [master]
2 BACKUP LOG [store] TO  DISK = N‘D:\sql_back\store_LogBackup_2019-01-30_10-44-29.bak‘ WITH NOFORMAT, NOINIT,  NAME = N‘store_LogBackup_2019-01-30_10-44-29‘, NOSKIP, NOREWIND, NOUNLOAD,  NORECOVERY ,  STATS = 5
3 RESTORE DATABASE [store] FROM  DISK = N‘E:\mssql\store.bak‘ WITH  FILE = 1,  MOVE N‘store‘ TO N‘D:\install\store.mdf‘,  MOVE N‘store_log‘ TO N‘D:\sql_data\store_log.LDF‘,  NOUNLOAD,  STATS = 5
4
5 GO

原文地址:https://www.cnblogs.com/neoo9901/p/10337012.html

时间: 2024-11-10 15:30:29

backup/restore database的相关文章

How to backup and restore database in SQL Server

/*By Dylan SUN*/ If you want to backup and restore one database in SQL Server. Firstly, create a shared folder, and add everyone with read/write right. Secondly, backup your database. You can use the following script : backup database DatabaseName to

SQL Service Database BACKUP & RESTORE

1. 完整恢复模式下的数据库备份 1 USE master; 2 ALTER DATABASE AdventureWorks2012 SET RECOVERY FULL; 3 GO 4 -- Back up the AdventureWorks2012 database to new media set (backup set 1). 5 BACKUP DATABASE AdventureWorks2012 6 TO DISK = 'Z:\SQLServerBackups\AdventureWo

RESTORE DATABASE命令还原SQLServer 数据库 bak

今天在sqlServer20005 的management studio里使用bak文件还原数据库的时候,总是失败!Restore failed for Server 'ADANDELI'.  (Microsoft.SqlServer.Smo)An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfoThe backup set holds

【翻译自mos文章】当控制文件的备份丢失是,怎么restore database

当控制文件的备份丢失是,怎么restore database? 来源于: How to restore database when controlfile backup missing (文档 ID 1438776.1) 适用于: Oracle Database - Enterprise Edition - Version 9.2.0.1 to 11.2.0.3 [Release 9.2 to 11.2] Information in this document applies to any p

转 RMAN: RAC Backup, Restore and Recovery using RMAN

PURPOSE The purpose of this document is to give a quick guide for using RMAN on RAC databases. We will follow this points: 1. Verify the database mode and archive destination.2. Verify connectivity using sqlnet for target and catalog.3. Determine the

SQL Server 还原错误“restore database正在异常终止 错误 3154”

今天在还原数据库时,先建立相同名字的数据库,然后在该数据库上右键还原数据库.遇到了这样的一个错误: “备份集中的数据库备份与现有的 'RM_DB' 数据库不同. RESTORE DATABASE 正在异常终止. (Microsoft SQL Server,错误: 3154) ” 很显然,这是由于备份的数据库版本和我现在还原的数据库版本不一样导致的. 最终通过以下方法解决了此类问题: (1)直接在“数据库”上右键菜单->还原文件和文件组 (2)直接写入数据库名字-RM_DB,点击确定,OK!还原成

RAC(11gR2) OCR BACKUP & RESTORE

首先检查下OCR盘 [[email protected]1 cdata]$ ocrcheck Status of OracleCluster Registry is as follows : Version                  :          3 Total space (kbytes)     :    262120 Used space (kbytes)      :      3068 Available space (kbytes) :     259052 ID  

sqlserver 2012数据还原,RESTORE DATABASE 正在异常终止。 (Microsoft SQL Server,错误: 3174)

使用差异性备份文件还原的时候报错: 报错时,通过生成的还原脚本可以看到: RESTORE DATABASE [m] FILE = N'm' FROM DISK = N'D:\m\m_backup_2016_04_07_280002_6355156.bak' WITH FILE = 1, MOVE N'm' TO N'D:\Program Files\Microsoft SQL Server\MSSQL11.YSMSTEST\MSSQL\DATA\\m.mdf', MOVE N'm_log' TO

Restore database use sql `*.bak` file

1.第一步: 2.第二步: 3.第三布: 4.第四步: