简体   繁体   English

数据库文件组-仅在新服务器上还原1个文件组

[英]Database Filegroups - Only restore 1 filegroup on new server

Is there a way to backup certain tables in a SQL Database? 有没有一种方法可以备份SQL数据库中的某些表? I know I can move certain tables into different filegroups and preform a backup on these filegroup. 我知道我可以将某些表移到不同的文件组中,并在这些文件组上进行备份。 The only issue with this is I believe you need a backup of all the filegroups and transaction logs to restore the database on a different server. 唯一的问题是,我认为您需要备份所有文件组和事务日志,才能在其他服务器上还原数据库。

The reason why I need to restore the backup on a different server is these are backups of customers database. 我需要在其他服务器上还原备份的原因是这些是客户数据库的备份。 For example we may have a remote customer and need to get a copy of they 4GB database. 例如,我们可能有一个远程客户,需要获得他们4GB数据库的副本。 90% of this space is taken up by two tables, we don't need these tables as they only store images. 两个表占用了90%的空间,我们不需要这些表,因为它们仅存储图像。 Currently we have to take a copy of the database and upload it to a FTP site…With larger databases this can take a lot of the time and we need to reduce the database size. 当前,我们必须复制数据库并将其上传到FTP站点…对于较大的数据库,这可能会花费大量时间,并且我们需要减小数据库的大小。

The other way I can think of doing this would be to take a full backup of the DB and restore it on the clients SQL server. 我可以想到的另一种方式是对数据库进行完整备份,然后将其还原到客户端SQL Server上。 Then connect to the new temp DB and drop the two tables. 然后连接到新的临时数据库并删除两个表。 Once this is done we could take a backup of the DB. 完成此操作后,我们可以备份数据库。 The only issue with this solution is that it could use a lot of system restores at the time of running the query so its less than ideal. 此解决方案的唯一问题是,在运行查询时,它可能会使用大量系统还原,因此其效果不理想。

So my idea was to use two filegroups. 所以我的想法是使用两个文件组。 The primary filegroup would host all of the tables except the two tables which would be in the second filegroup. 主文件组将托管所有表,但第二个文件组中的两个表除外。 Then when we need a copy of the database we just take a backup of the primary filegroup. 然后,当我们需要数据库副本时,我们只需备份主文件组。 I have done some testing but have been unable to get it working. 我已经进行了一些测试,但是无法正常工作。 Any suggestions? 有什么建议么? Thanks 谢谢

Basically your approach using 2 filegroups seems reasonable. 基本上,使用2个文件组的方法似乎是合理的。

I suppose you're working with SQL Server on both ends, but you should clarify for each which whether that is truly the case as well as which editions (enterprise, standard, express etc.), and which releases 2000, 2005, 2008, (2012 ? ). 我想您正在使用SQL Server的两端,但是您应该分别说明每种情况是否确实如此,以及哪个版本(企业版,标准版,快速版等)以及哪个发行版2000、2005、2008, (2012年?)。

Table backup in SQL Server is here a dead horse that still gets a good whippin' now and again. SQL Server中的表备份在这里是一匹致命的马,仍然时不时地引起人们的关注。 Basically, that's not a feature in the built-in backup feature-set. 基本上,这不是内置备份功能集中的功能。 As you rightly point out, the partial backup feature can be used as a workaround. 正如您正确指出的那样,可以将部分备份功能用作解决方法。 Also, if you just want to transfer a snapshot from a subset of tables to another server, using ftp you might try working with the bcp utility as suggested by one of the answers in the above linked post, or the export/import data wizards. 另外,如果您只是想将快照从表的子集转移到另一台服务器,则可以使用ftp尝试使用bcp实用程序,如上面链接的文章中的答案之一或导出/导入数据向导所建议的那样。 To round out the list of table backup solutions and workarounds for SQL Server, there is this (and possibly other ? ) third party software that claims to allow individual recovery of table objects, but unfortunately doesn't seem to offer individual object backup, "Object Level Recovery Native" by Red Gate" . (I have no affiliation or experience using this particular tool). 为了完善的表备份解决方案,并为SQL Server解决方法列表,有这个(可能还有其他?)第三方索赔,让表对象的个体回收,但遗憾的是似乎并没有提供单独的对象备份软件, “对象级别恢复本机“由Red Gate” (我没有使用该特定工具的隶属关系或经验)。

As per your more specific concern about restore from partial database backups : 根据您对从部分数据库备份还原的更具体的关注:

I believe you need a backup of all the filegroups and transaction logs to restore the database on a different server 我相信您需要所有文件组和事务日志的备份,才能在其他服务器上还原数据库

1) You might have some difficulties your first time trying to get it to work, but you can perform restores from partial backups as far back as SQL Server 2000, (as a reference see here 1)首次尝试使用它时可能会遇到一些困难,但是您可以从SQL Server 2000之前的部分备份中执行还原,(请参阅此处的参考资料)

2) From 2005 and onward you have the option of partially restoring today, and if you need to you can later restore the remainder of your database. 2)从2005年起,您可以选择今天进行部分还原,并且如果需要,可以稍后还原数据库的其余部分。 You don't need to include all filegroups-you always include the primary filegroup and if your database is simple recovery mode you need to add all read-write filegroups. 您不需要包括所有文件组-您始终包括主文件组,并且如果数据库是简单恢复模式,则需要添加所有读写文件组。

3) You need to apply log backups only if your db is in bulk or full recovery mode and you are restoring changes to a readonly filegroup that since last restore has become read-write. 3)仅当数据库处于批量或完全恢复模式并且要将更改还原到自上次还原以来已变为读写的只读文件组时,才需要应用日志备份。 Since you are expecting changes to these tables you will likely not be concerned about read only filegroups, and so not concerned about shipping and applying log backups 由于您期望对这些表进行更改,因此您可能不必担心只读文件组,因此不必担心运送和应用日志备份

You might also investigate some time whether any of the other SQL Server features, merge replication, or those mentioned above (bcp, import/export wizards) might provide a solution that is more simple or more adequately meets your needs. 您可能还会调查一段时间,是否其他任何SQL Server功能,合并复制或上述功能(bcp,导入/导出向导)是否可以提供更简单或更充分满足您需求的解决方案。

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

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