简体   繁体   English

恢复 SQL 备份 .bak 和多个差异备份

[英]Restoring a SQL backup .bak and multiple differential backups

We work with a client who has a SQL database that we got a backup of at first, and they send us differential backups every month.我们与一个拥有 SQL 数据库的客户合作,我们最初得到了备份,他们每个月都会向我们发送差异备份。 So far what I've had to do each month is completely delete the database, restore it from the original .bak with NORECOVERY, and then restore the differentials one by one each with NORECOVERY.到目前为止,我每个月都必须完全删除数据库,使用 NORECOVERY 从原始 .bak 恢复它,然后使用 NORECOVERY 逐个恢复差异。 Then when I reach the last differential, I'll make the database live so I can query it with a .sql query然后当我达到最后一个差异时,我将使数据库处于活动状态,以便我可以使用 .sql 查询对其进行查询

Is it possible to restore all the differentials at once?是否可以一次恢复所有差异? Doing it one by one is a huge pain, and redoing the whole process every month is even more a pain.一个一个地做是一个巨大的痛苦,每个月重做整个过程更痛苦。

在此处输入图像描述

在此处输入图像描述

You don't have to restore all the differentials one by one, you have to restore only the latest one.您不必一一恢复所有差异,您只需恢复最新的差异。

A differential backup has all the changes since the last FULL backup, not from the last DIFF backup.差异备份包含自上次FULL备份以来的所有更改,而不是上次DIFF备份的所有更改。

In your example you can restore only the JCIHistorianDB.bak with no recovery, then JCIHistorianDB-Diff_2022-07-13.bak with recovery.在您的示例中,您可以仅恢复JCIHistorianDB.bak而不恢复,然后恢复JCIHistorianDB-Diff_2022-07-13.bak

You would restore one of the others, to see how the database was in that day, but if you always want the latest state of the database, you need only the latest DIFF backup.您将恢复其中一个,以查看数据库在当天的情况,但如果您总是想要数据库的最新状态,则只需要最新的 DIFF 备份。

And of course as @Stu suggested, you can make this task even more automatical with a script.当然,正如@Stu 建议的那样,您可以使用脚本使这项任务更加自动化。

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

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