简体   繁体   English

简单快速的sql server数据库备份和恢复

[英]simple & fast sql server database backup and restore

I'm looking for a simple (simplest if possible) way of backing up and restoring a database. 我正在寻找一种简单(如果可能的话)最简单的备份和恢复数据库的方法。

I want to do a backup in one state and then after doing some operations get back to the backed up state. 我想在一个状态下进行备份,然后在执行某些操作后返回到备份状态。

Tried Database->Tasks->Back Up... and then Database->Tasks->Restore but I always get an error with: 尝试数据库 - >任务 - >备份...然后数据库 - >任务 - >恢复,但我总是得到一个错误:

Restore failed for...DBName

The tail of the log for the database "database name" has not been backed up...

So, I want to back up and restore with one simple operation each, can one advise me to a solution, be it GUI or not GUI based? 所以,我想通过一个简单的操作备份和恢复每个,可以建议我一个解决方案,无论是GUI还是不基于GUI?

Use the WITH REPLACE option of the RESTORE command: 使用RESTORE命令的WITH REPLACE选项:

The REPLACE option overrides several important safety checks that restore normally performs. REPLACE选项会覆盖恢复正常执行的几个重要安全检查。 The overridden checks are as follows: 被覆盖的检查如下:

  • Restoring over an existing database with a backup taken of another database. 使用另一个数据库的备份还原现有数据库。 With the REPLACE option, restore allows you to overwrite an existing database with whatever database is in the backup set, even if the specified database name differs from the database name recorded in the backup set. 使用REPLACE选项,还原允许您使用备份集中的任何数据库覆盖现有数据库,即使指定的数据库名称与备份集中记录的数据库名称不同也是如此。 This can result in accidentally overwriting a database by a different database. 这可能导致意外地由不同的数据库覆盖数据库。
  • Restoring over a database using the full or bulk-logged recovery model where a tail-log backup has not been taken and the STOPAT option is not used . 使用完整或大容量日志恢复模型在数据库上进行还原,其中未执行尾部日志备份且未使用STOPAT选项 With the REPLACE option, you can lose committed work, because the log written most recently has not been backed up. 使用REPLACE选项,您可能会丢失已提交的工作,因为最近编写的日志尚未备份。
  • Overwriting existing files. 覆盖现有文件。 For example, a mistake could allow overwriting files of the wrong type, such as .xls files, or that are being used by another database that is not online. 例如,错误可能允许覆盖错误类型的文件,例如.xls文件,或者由不在线的其他数据库使用的文件。 Arbitrary data loss is possible if existing files are overwritten, although the restored database is complete. 如果现有文件被覆盖,则可能会丢失任意数据,尽管已恢复的数据库已完成。

The topic is also covered at nauseam in MSDN see Restoring Without Using a Tail-Log Backup , which contains the links for 'How to' articles that cover Management Studio scenarios (ie. the tool you're using). MSDN中的恶心还介绍了该主题,请参阅“ 不使用尾部日志备份进行恢复” ,其中包含涵盖Management Studio场景的“如何”文章的链接(即您正在使用的工具)。

It looks like you have Differential Backups set up. 您似乎已设置差异备份。 It is slightly more complicated than restoring a Full backup. 它比恢复完整备份稍微复杂一些。

http://msdn.microsoft.com/en-us/library/ms175510.aspx http://msdn.microsoft.com/en-us/library/ms175510.aspx

By doing a Full backup, you are going to break the chain of backups that the DBA set up, so it would be a good idea to check first with the DBA before you break his backup set. 通过执行完全备份,您将打破DBA设置的备份链,因此在断开备份集之前首先检查DBA是个好主意。

Edited for very helpful comments: 编辑非常有用的评论:

You should use the COPY_ONLY option when you do a backup so that you do not break the chain of backups. 执行备份时应使用COPY_ONLY选项,这样就不会破坏备份链。

http://msdn.microsoft.com/en-us/library/ms186865.aspx http://msdn.microsoft.com/en-us/library/ms186865.aspx

When restoring you need to check the option to Overwrite existing database, if you are, otherwise it will fail. 在恢复时,您需要选中覆盖现有数据库的选项,否则它将失败。

MSSQL 2005 and up features snapshots , sounds like it suits your requirements nicely. MSSQL 2005及以上功能快照 ,听起来很适合您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM