简体   繁体   English

如何在不增加文件缓存的情况下将大文件复制到 Windows 中的网络共享/从网络共享复制? PowerShell 或 .NET,理想情况下

[英]How can I copy a large file to/from a network share in Windows without inflating the file cache? PowerShell or .NET, ideally

I am working with dedicated Windows 2008 R2 and 2003 SQL Servers;我正在使用专用的 Windows 2008 R2 和 2003 SQL Server; throughout the day and night I need to copy large files off the machines to network shares for backup and log shipping.整个白天和黑夜,我需要将大型文件从机器复制到网络共享以进行备份和日志传送。

There's a documented issue where the OS will allocate a lot of memory to the file cache to handle these copies, and that robs memory, potentially, from other functions.有一个记录在案的问题,操作系统会为文件缓存分配大量内存来处理这些副本,这可能会从其他功能中抢夺内存。 (Eventually on Win2k8 R2, Task Manager reports Free Memory = 0 as the result of this behavior.) But these particular files are never read after the copy, and the "just in case" caching of the file data doesn't make sense for this function. (最终在 Win2k8 R2 上,任务管理器报告 Free Memory = 0 作为此行为的结果。)但是这些特定文件在复制后永远不会被读取,并且文件数据的“以防万一”缓存对于这个功能。

Is there a simple .NET or PowerShell way to copy files and not have this file cache grow?是否有一种简单的 .NET 或 PowerShell 方法来复制文件并且不让此文件缓存增长? The biggest file I am dealing with, for reference, is 300+ GB.作为参考,我正在处理的最大文件是 300+ GB。

We currently use RoboCopy on 2008 R2, xcopy on 2003, and SQL Server's own Log Shipping file copy job for this function.我们目前在 2008 R2 上使用 RoboCopy,在 2003 上使用 xcopy,并为此功能使用 SQL Server 自己的日志传送文件复制作业。

I have heard about a /J switch in XCOPY in win2k8R2, and a special DLL from Exchange that some argue helps this issue but it would be nice to have a really clean and simple solution.我听说过 win2k8R2 中 XCOPY 中的 /J 开关,以及来自 Exchange 的特殊 DLL,有人认为这有助于解决这个问题,但如果有一个真正干净和简单的解决方案会很好。

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

When I copy large amounts of data, I use Robocopy because I have run into problems with other options, eg XCOPY, Copy-Item, etc.当我复制大量数据时,我使用 Robocopy,因为我遇到了其他选项的问题,例如 XCOPY、Copy-Item 等。

My Robocopy script:我的 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

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

相关问题 如何在没有CopyFile或CopyFileEx的情况下在Windows上复制大文件? - How can I copy a large file on Windows without CopyFile or CopyFileEx? 不使用 windows 文件缓存复制文件 - Copy a file without using the windows file cache 使用C#(.NET Core)将文件从Linux复制到Windows共享 - Copy file from linux to windows share with C# (.NET core) 如何从Windows服务将文件复制到网络位置? - How to Copy a file to Network Location from Windows Service? 有没有什么想法可以将文件复制到没有共享文件夹的其他Windows服务器 - Is there any idea to copy file to another windows server without share folder 使用.NET追加到大文件时,如何避免过多的网络文件I / O? - How do I avoid excessive Network File I/O when appending to a large file with .NET? 在Windows 7网络共享上访问文件的更快方法? - Faster way to access a file on a Windows 7 network share? 如何在不加载到内存的情况下对大型csv文件进行排序 - How can i sort large csv file without loading to memory 我可以从ASP.net向SQL Server中插入一个大文本值,而不必将整个文件放在Web服务器的内存中吗? - Can I insert a large text value into SQL Server from ASP.net without having the whole file in memory on the webserver? 如何在.NET中的大文件中间插入或删除字节 - How can I insert or remove bytes from the middle of a large file in .NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM