如题,按例子上的做,备份到的文件都还原不了,有没有哪位大大做过?
------解决方案--------------------
还原的时候要加上with replace 强制覆盖。
------解决方案--------------------
- SQL code
--完整备份Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Full_20070908.bak'--差异备份Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Diff_20070908.bak'With Differential--日志备份,默认截断日志Backup Log NorthwindCSTo disk='G:\Backup\NorthwindCS_Log_20070908.bak'--日志备份,不截断日志Backup Log NorthwindCSTo disk='G:\Backup\NorthwindCS_Log_20070908.bak'With No_Truncate--截断日志不保留Backup Log NorthwindCSWith No_Log--或者Backup Log NorthwindCSWith Truncate_Only--截断之后日志文件不会变小--有必要可以进行收缩--文件备份Exec Sp_Helpdb NorthwindCS --查看数据文件Backup Database NorthwindCSFile='NorthwindCS' --数据文件的逻辑名To disk='G:\Backup\NorthwindCS_File_20070908.bak'--文件组备份Exec Sp_Helpdb NorthwindCS --查看数据文件Backup Database NorthwindCSFileGroup='Primary' --数据文件的逻辑名To disk='G:\Backup\NorthwindCS_FileGroup_20070908.bak'With init--分割备份到多个目标--恢复的时候不允许丢失任何一个目标Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Full_1.bak' ,disk='G:\Backup\NorthwindCS_Full_2.bak'--镜像备份--每个目标都是相同的Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Mirror_1.bak'Mirror To disk='G:\Backup\NorthwindCS_Mirror_2.bak'With Format --第一次做镜像备份的时候格式化目标--镜像备份到本地和远程Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Mirror_1.bak'Mirror To disk='\\192.168.1.200\Backup\NorthwindCS_Mirror_2.bak'With Format--每天生成一个备份文件Declare @Path Nvarchar(2000)Set @Path ='G:\Backup\NorthwindCS_Full_'+Convert(Nvarchar,Getdate(),112)+'.bak'Backup Database NorthwindCSTo --从NoRecovery或者--Standby模式恢复数据库为可用Restore Database NorthwindCS_BakWith Recovery--查看目标备份中的备份集Restore HeaderOnlyFrom Disk ='G:\Backup\NorthwindCS_Full_20070908.bak'--查看目标备份的第一个备份集的信息Restore FileListOnlyFrom Disk ='G:\Backup\NorthwindCS_Full_20070908_2.bak'With File=1--查看目标备份的卷标Restore LabelOnlyFrom Disk ='G:\Backup\NorthwindCS_Full_20070908_2.bak'--备份设置密码保护备份Backup Database NorthwindCSTo disk='G:\Backup\NorthwindCS_Full_20070908.bak'With Password = '123',initRestore Database NorthwindCSFrom disk='G:\Backup\NorthwindCS_Full_20070908.bak'With Password = '123'===================================sql 2000一、指定逻辑备份设备 backup databse accounting to accounting_bak二、或指定物理备份设备 backup database accouning to disk='d:\backup\accouning\full.bak'三、执行无日志操作后的命令 backup log with truncate_only writetext 或 backup log with NO_log updatetext select ... into....四、设置数据库的还原模型 1、完全模型 alter database northwind set recovery full 2、简单模型 alter database norhtwind set recovery simple 3、大容量日志记录bulk_logged模型 alter database northwind set recovery bulk_logged五、添加备份设备 sp_addumpdevice 'disk','NWdevice','d:\backup\mydevice.bak'六、删除一个备份设备 sp_dropdevice 'nwdevice','delfile' /*如果加上delfile就是直接把文件也删除掉*/七、差异备份的语法 backup database northwind to nwdevice with differential八、事务日志备份 backup log company to NWdevice with no_truncate(不清空原有日志)九、文件和文件组备份及还原 backup database commpany filegroup='primary' to NWdevice 文件组的名称是"primary"十、数据恢复(从硬盘恢复) restore database company from disk='d:\backup\company.bak' 还可继续在后面加参数: with nonrecovery recovery replace 注: (1)recovery:最后一次一次恢复时使用 (2)replace:是否替换己有文件
------解决方案--------------------
- SQL code
RESTORE DATABASE [aaa] FILE = N'AdventureWorks_Data' FROM DISK = N'D:\AdventureWorks.bak' WITH FILE = 1, MOVE N'AdventureWorks_Data' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\aaa.mdf', MOVE N'AdventureWorks_Log' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\aaa_0.ldf', NOUNLOAD, REPLACE, STATS = 10GO