批量备份 - 溢出

时间:2014-01-03 17:35:56

标签: batch-file if-statement overflow robocopy

我使用Robocopy创建了一个不错的批量备份。我试图找出如何告诉我的批处理文件如果目标如果已满,如何从dest_dir切换到dest_dir1。一种溢出备份系统。这可能是robocopy,还是我需要使用IF语句?如果答案是正确的,我道歉,我只是不明白。

我有什么

  Robocopy %RevFileAdminBackup% %dest_dir% %_options%

如果%dest_dir%已满Robocopy %RevFileAdminBackup% %dest_dir1% %_options%。我怎么能这样做?

编辑(2014年1月8日):这是我所拥有的,不起作用。

@ECHO OFF

REM DVD Drives \\SHARE\DVD1$
REM DVD Drives \\SHAREDVD2$

REM SET Variables to Path

SET dest_dir=""
SETdest_dir1 =""

SET _log=/LOG+:logfile.txt

SET _options= /MOVE /R:0 /W:20 /XD /E /XX
SET RevFileAdminBackup= ""

IF EXIST %RevFileAdminBackup% (
    GOTO AUTOAdminRevBurn
)


:AUTOAdminRevBurn
REM copy to the 1st destination.
REM IF 1st destination full go to seconddisk

robocopy %RevFileAdminBackup% %dest_dir% %_options%
if errorlevel 16 goto seconddisk



:seconddisk
msg /TIME:9999 * D Drive Full.
robocopy %RevFileAdminBackup% %dest_dir1% %_options%

1 个答案:

答案 0 :(得分:2)

Robocopy有各种exit codes。用它们来处理你需要的东西。在一个完整的情况下,我相信你会得到一个错误级别> = 8,所以这样的事情会起作用:

REM copy to the 1st destination
robocopy %RevFileAdminBackup% %dest_dir% %_options%
if not errorlevel 8 goto finished
REM if that didn't work then try again at the 2nd destination
robocopy %RevFileAdminBackup% %dest_dir1% %_options%
:finished