Hello all,
I created small cmd batch file, that checks CRC checksum of test file and compares it to previously calculated checksum. If these values are equal, then the file wasn't changed (i.e. encrypted by ransomware) and the backup can proceed. If the CRC isn't correct, the backup task should cancel. But regardles the exit code of cmd task, Cobian always performs the backup, even if I have "Cancel the task if some event fails" checked. Is there any special exit code, that Cobian listens to, or should I force the cmd to somehow crash?
The fact is, that the cmd batch file always runs and ends and the Cobian probably doesn't check the error code.
My test_CRC.cmd file code:
for /f "tokens=*" %%a in ('CertUtil -hashfile "E:\CRC_check_File.txt" SHA256 ^| FIND /V "CertUtil" ^| FIND /V "SHA256"') do set _CmdResult=%%a
ECHO !_CmdResult! >> log.txt
for /f "delims=" %%x in (E:\CRC_checksum.txt) do set CRC=%%x
ECHO !CRC! >> log.txt
if %_CmdResult% EQU %CRC% (ECHO OK) ELSE (ECHO CRC ERROR
waitfor /T 5 pause) @REM This is wrong command and causes error
DEL R:\text.txt @REM try to delete NON-EXISTENT file to cause error
exit -1 @REM try to exit cmd with non 0 exit code
Cobian Pre-backup event setting:
EXECUTEANDWAIT,E:\test_CRC.cmd,
Cancel the task if some event fails is checked
Many Thaks for help.
The purpose of this CRC check is to prevent backup of possibly encrypted files after ransomware attack, which happened to me and i lost some valuable data, because the Cobian was still running after the attack and the backup rewrote previous files on remote backup location.
How Cobian registers failed Pre-backup event?
Re: How Cobian registers failed Pre-backup event?
Exit codes are, unfortunately, not supported yet.
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: How Cobian registers failed Pre-backup event?
Ok, so does it mean, that the option "Cancel the task if some event fails" is basically ignored?
Or does Cobian check/react to any event/crash?
I wonder how to force stop the backup if files are corrupted and in best case send an email...
Or does Cobian check/react to any event/crash?
I wonder how to force stop the backup if files are corrupted and in best case send an email...
Re: How Cobian registers failed Pre-backup event?
Well, yes, it reacts for example to a service failing to be started or a program to be executed or a "file not found" when opening a file, etc. Pretty limited, I know.
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: How Cobian registers failed Pre-backup event?
That is something I can work with, many thanks!
I changed my CRC check script a bit, so it creates another simple batch file if succesfully verifies the CRC and then I execute another command just to run this new batch file (it contains "ECHO OK" ).
If the CRC is not verified - the first script deletes the secondary batch file and then Cobian can't execute it and therefore the task fails.
Which is exactly what I needed.
Only setback which I had, is that I have Cobian installed as service and if you do not specify absolute paths into scripts, then it creates/deletes file "somewhere".
I hope this helps someone else if they are looking something similar.
Of course it would be great, if Cobian could react to exit codes. That would be much elegant...
I changed my CRC check script a bit, so it creates another simple batch file if succesfully verifies the CRC and then I execute another command just to run this new batch file (it contains "ECHO OK" ).
If the CRC is not verified - the first script deletes the secondary batch file and then Cobian can't execute it and therefore the task fails.
Which is exactly what I needed.
Only setback which I had, is that I have Cobian installed as service and if you do not specify absolute paths into scripts, then it creates/deletes file "somewhere".
I hope this helps someone else if they are looking something similar.
Of course it would be great, if Cobian could react to exit codes. That would be much elegant...