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

时间: 01-30

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-06023: no backup or copy of datafile 16 found to restore

RMAN> restore database; Starting restore at 2017-03-02 12:03:05 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=4269 instance=cqdb device type=DISK allocated channel: ORA_DISK_2 cha

SQL2005中使用backup、restore来备份和恢复数据库

在SQL2005数据库中利用SQL语句进行数据备份与还原: 备份backup:backup database 数据库名称 tO disk = 备份路径例:BACKUP DATABASE test TO disk = 'd:\bak\test.bak' 恢复restore:restore  database 数据库名称from disk = 备份路径例:RESTORE DATABASE test FROM disk = 'd:\bak\test.bak'

RMAN-06023: no backup or copy of datafile 1 found to restore

在ORACLE 10g数据库还原过程遭遇RMAN-06023: no backup or copy of datafile x found to restore,具体情况如下所示 ..................................................................................... File Name: /u03/flash_recovery_area/EPPS/archivelog/2015_01_26/o1_mf_1_10_

异机恢复 RMAN-06023: no backup or copy of datafile 17 found to restore

前不久因工作需要使用RMAN异机恢复,很基础也很具有代表性和普遍性,希望对需要的人有所帮助. 具体过程如下: 先拷贝原库的口令文件和参数文件到备库. 然后使用如下脚本对原库进行备份: run { allocate channel d1 type disk; allocate channel d2 type disk; backup full database format'c:\rmanbak\date%Y%m%d_full_%d_%s_%p_%u.bak' tag='full' include

Restore Oracle database to another server

1. Copy or remotely mount the backupset folder from the source server to the target server 2. On the target server, export ORACLE_SID as same as the source database and run "rman target /" 3. Restore spfile from backup: RMAN> startup nomount;

第一章、关于SQL Server数据库的备份和还原(sp_addumpdevice、backup、Restore)

在sql server数据库中,备份和还原都只能在服务器上进行,备份的数据文件在服务器上,还原的数据文件也只能在服务器上,当在非服务器的机器上启动sql server客户端的时候,也可以通过该客户端来备份和还原数据库,但是这种操作实质是在服务器上进行的,备份的数据文件在服务器上,还原的数据文件也只能在服务器上,这个原则不会变,只是使用了客户端的一个工具来操作这个过程而已. 1.1.备份数据库 备份数据库有两种方式: 第一种是在企业管理器中,利用工具对数据库进行备份,这种备份的文件只会有一个,即以