【问题标题】:How can I copy a large file to/from a network share in Windows without inflating the file cache? PowerShell or .NET, ideally如何在不增加文件缓存的情况下将大文件复制到/从 Windows 中的网络共享? PowerShell 或 .NET,理想情况下
【发布时间】:2012-03-20 08:45:21
【问题描述】:

我正在使用专用的 Windows 2008 R2 和 2003 SQL Server;整个白天和晚上,我都需要将大型文件从机器上复制到网络共享以进行备份和日志传送。

有一个记录在案的问题是,操作系统会为文件缓存分配大量内存来处理这些副本,这可能会从其他功能中抢走内存。 (最终在 Win2k8 R2 上,任务管理器报告 Free Memory = 0 作为此行为的结果。)但是这些特定文件在复制后读取,并且文件的“以防万一”缓存data 对这个函数没有意义。

是否有一种简单的 .NET 或 PowerShell 方法来复制文件而不增加此文件缓存?作为参考,我正在处理的最大文件是 300+ GB。

我们目前在 2008 R2 上使用 RoboCopy,在 2003 上使用 xcopy,并为此功能使用 SQL Server 自己的 Log Shipping 文件复制作业。

我听说过 win2k8R2 中 XCOPY 中的 /J 开关,以及来自 Exchange 的一个特殊 DLL,有人认为它有助于解决这个问题,但如果有一个非常干净和简单的解决方案会很好。

另见http://blogs.msdn.com/b/ntdebugging/archive/2007/11/27/too-much-cache.aspx

【问题讨论】:

  • 你试过 Robocopy 吗?
  • 目前复制任务是如何完成的...?有很多方法可以做到这一点,但必须展示或展示非健壮代码当前是如何工作的。
  • 编辑添加当前方法
  • 什么操作系统?如果您可以访问 powershell v2,我会考虑使用它和 BIT 进行传输:blogs.msdn.com/b/powershell/archive/2009/01/11/…

标签: c# windows powershell


【解决方案1】:

当我复制大量数据时,我使用 Robocopy,因为我遇到了其他选项的问题,例如XCOPY、Copy-Item 等。

我的 Robocopy 脚本:

#Source folder
$src = "" 

#Destination folder
$dest = "" 

<#Robocopy options: 
E = Copy subdirectories, including empty directories.
V = Verbose output
ZB = Restartable & backup mode (to handle network connectivity issues & disruptions)
COPY DAT = Copy Data, Attributes, and Timestamps. Add 'S' to include ACL/permissions.
XJ = Exclude junction points.
#>
$options = @("/E","/V","/ZB", "/COPY:DAT", "/XJ")

#Store src, dest, and other previously defined options in an array.
$cmdArgs = @($src, $dest, $options)

#Execute!
robocopy @cmdArgs

【讨论】:

    猜你喜欢
    • 2010-09-08
    • 2021-03-09
    • 2021-03-25
    • 2011-12-02
    • 1970-01-01
    • 2015-04-13
    • 2018-11-17
    • 2021-02-18
    • 2014-10-13
    相关资源
    最近更新 更多