如何让 TFS 自动删除旧版本的文件?
我有一个 Team Foundation Server,可用磁盘空间有限。为了维护它,我需要删除它存储的旧版本的文件。
理想情况下,我只希望它在以下情况下删除版本:
- 它早于特定日期,并且
- 它至少有 15 个版本
我该如何执行此操作?
I have a Team Foundation Server which has limited disk space available. In order to maintain it I need to delete older versions of the files that it stores.
Ideally, I would only want it to delete the version if:
- It is older than particular date, and
- It has a minimum of 15 versions
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有标准的方法可以做到这一点,这是有原因的。 TFS 通常会尝试仅存储基本文件和其上的差异,因此如果您开始删除旧版本,您将不会获得太多收益。至多这两个版本的差异大小。
升级 TFS 服务器的磁盘空间绝对是长期解决方案。
如果您必须缩小项目的规模,请考虑销毁不再使用的旧分支。 您可以销毁整个文件和文件夹,这将从 TFS 中删除它们以及与其关联的历史记录。默认情况下,您只能通过命令行访问此功能,并且您需要拥有销毁 TFS 中项目的权限。 源代码管理资源管理器有一个扩展,可将 Destroy 命令添加到上下文中Visual Studio 中的菜单。
如果您从 Team Build 服务器运行自动化测试,则测试附件也可能是 TFS 服务器超出其分配空间的原因。 Microsoft 发布了一个命令行实用程序来清理测试附件。
如果您确实想重置版本历史记录,您可以将代码分支到一个干净的团队项目,然后停用旧项目。
There is no standard way to do this, and there's a reason for this. TFS usually tries to store just the base file and the differences on top of that, so if you start removing older revisions, you won't be gaining much. At most the size of the diff of these two versions.
Upgrading the disk space of your TFS Server is definitely the long term solution here.
If you must reduce the size of your projects, consider destroying old branches that have no use anymore. You can destroy whole files and folders which will remove them and the history associated to them from TFS. By default you can only access this feature through the commandline and you need to have permission to destroy items in TFS. There is an extension for the Source Control Explorer that adds the Destroy command to the context menu in Visual Studio.
If you're running automated tests from a Team Build server, then test attachments may also be a reason for your TFS server growing out of its allotted space. Microsoft released a command line utility to clean up the Test Attachments.
If you truly want to reset the version history you could branch your code to a clean Team Project and then decommission the old one.
您还应该确定 TFS 的哪个组件使用的磁盘空间最多。
您可以在
Tfs_Collection
数据库上运行以下 SQL 查询来查看哪些表占用的空间最多。如果您使用 Microsoft 测试管理器,则测试附件使用的空间可能比您想象的要多。请查看此博客文章,了解有关如何解释此查询以及执行操作的更多信息:TFS2010:测试附件清理器以及为什么应该使用它
You should also be sure of which component of TFS is using the most disk space.
You can run the following SQL query on your
Tfs_Collection
database to see which tables are consuming the most space.If you are using Microsoft Test Manager, it's possible that Test Attachments are using more space than you thought. Take a look at this blog post for more information on how to interpret this query and what to do: TFS2010: Test Attachment Cleaner and why you should be using it