复制脚本暂停,并在遇到磁盘空间不足时无法完成 [英] Copy script pauses and fails to complete when it encounters insufficient disk space

查看:139
本文介绍了复制脚本暂停,并在遇到磁盘空间不足时无法完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个脚本,将最新的完整备份和增量复制到USB设备。我已经让脚本工作正常,因为它识别最新的备份并复制所有正确的文件(欢呼!),问题是我无法获得
错误处理才能正常工作。我有它的工作,所以它检测是否没有复制文件,但如果检测到磁盘空间不足,复制暂停等待用户插入另一个设备复制到并按Enter键,这意味着
错误处理脚本的一部分永远不会运行所以我从未收到过这种情况的警报。


这是到目前为止的脚本:


================= ================


pushd" \\\\
as\backup \ bit-cw backup"

for / f" tokens = *" %% a in('dir / b / od * .spf')设置newest = %% a

set noext =%newest:~0,-4%

xcopy"\\\\
as\backup \ bit-cw backup \%noext%*" " E:\" / y / c> %temp%\ error.txt

find" 0 File(s)copies" < %temp%\ error.txt> nul

如果%ERRORLEVEL%EQU 0(

eventcreate / SO" XCOPY" / T Information / L System / ID 999 / D"没有找到任何文件要复制。"


查找"当前磁盘上的磁盘空间不足" < %temp%\ error.txt> nul

if%ERRORLEVEL%EQU 0(

eventcreate / SO" XCOPY" / T Information / L System / ID 999 / D"当前磁盘上的磁盘空间不足。"$


del%temp%\ error.txt

popd


=================================


我认为我需要编辑xcopy线以某种方式让它在遇到空间不足的磁盘时终止,但我无法弄清楚如何做到这一点。任何帮助将不胜感激!!

解决方案

使用robocopy而不是xcopy(使用/ r:0 / w:0)将解决您的问题。

I'm trying to get a script running that will copy the latest full backup and incrementals to a USB device. I have got the script working OK in so far as it identifies the latest backup and copies all the correct files (hurrah!), the problem is I can't get the error handling to work correctly. I have it working so it detects if no files are copied but in the event that insufficient disk space is detected the copy pauses waiting for the user to insert another device to copy to and press enter, this means that the error handling part of the script never runs so I never receive the alert that this has happened.

This is the script so far:

=================================

pushd "\\nas\backup\bit-cw backup"
for /f "tokens=*" %%a in ('dir /b /od *.spf') do set newest=%%a
set noext=%newest:~0,-4%
xcopy "\\nas\backup\bit-cw backup\%noext%*" "E:\" /y /c > %temp%\error.txt
find "0 File(s) copied" < %temp%\error.txt > nul
if %ERRORLEVEL% EQU 0 (
eventcreate /SO "XCOPY" /T Information /L System /ID 999 /D "No files were found to copy."
)
find "Insufficient disk space on current disk" < %temp%\error.txt > nul
if %ERRORLEVEL% EQU 0 (
eventcreate /SO "XCOPY" /T Information /L System /ID 999 /D "Insufficient disk space on current disk."
)
del %temp%\error.txt
popd

=================================

I assume that I need to edit the xcopy line to somehow get it to terminate when it encounters a disk with insufficient space but I can't figure out how to do it. Any help would be greatly appreciated!!

解决方案

Using robocopy instead of xcopy (with /r:0 /w:0) will solve your problem.


这篇关于复制脚本暂停,并在遇到磁盘空间不足时无法完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆