Checking the existance of destination directory

Questions about Cobian Reflector
User avatar
cobian
Site Admin
Posts: 4734
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: Checking the existance of destination directory

Post by cobian »

The problem is that sometimes the destination is not available at the start, but it is mounted as a pre-backup event, so if the existence is checked before then such backups will not be possible.
--
Luis Cobian
Cobian Backup's creator
ira
Posts: 103
Joined: 02 Nov 2021, 19:16

Re: Checking the existance of destination directory

Post by ira »

You might be able to create a batch file with a line like this:

if not exist c:\lists.txt exit 7

and then don't continue backup on error be checking "Cancel the task if some event fails."
User avatar
cobian
Site Admin
Posts: 4734
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: Checking the existance of destination directory

Post by cobian »

You need to return a non zero value in your script in order for the task to be aborted.
--
Luis Cobian
Cobian Backup's creator
ira
Posts: 103
Joined: 02 Nov 2021, 19:16

Re: Checking the existance of destination directory

Post by ira »

I thought that's what my example does, return 7 when the file is missing.
User avatar
cobian
Site Admin
Posts: 4734
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: Checking the existance of destination directory

Post by cobian »

But do you have options/ Engine/Anlalyze exit code for "Execute and wait" events checked?
--
Luis Cobian
Cobian Backup's creator
ira
Posts: 103
Joined: 02 Nov 2021, 19:16

Re: Checking the existance of destination directory

Post by ira »

Sorry, I know how to do this, I was trying to help the poster and I pointed out that needed to be checked.
mrtn
Posts: 3
Joined: 01 Feb 2022, 08:47

Re: Checking the existance of destination directory

Post by mrtn »

Hi, first of all I'd like to thank you for a excelent job with Cobian Reflector.

I have the same problem, but for different reason.
Namely, my local Home NAS is not avilable when I'm on VPN. And it's almost impossible for me to fix this on network, becouse I actualy use 3 different VPN-s for different servers.
So, in case of beeing on VPN, Cobian creates local zip file, then clears Archive flag and then tries to copy zip to NAS, but fails. And deletes zip afterwards. Or, in case of full backup, it creates full backups zip, marks (somehow) that full backup has been created and then tries to copy it... with the same result.

This actualy resulted in me loosing some files, becouse I had 3 increments of a folder, but no (new) full backup of it.

My suggestion would be just to change the order of operations. In case of full backup:
  1. create zip
  2. try top copy file to destination
  3. delete zip
  4. if copy sucessful: mark that full backup has been created
And in case of incremental backup:
  1. create zip
  2. try top copy...
  3. delete zip
  4. if copy sucessful: delete achive flag on files
In this case the result would be:
  • If full backup is unsucessful, Cobian will retry create full backup at nbext occasion (next day)
  • if incremental backup is unsucessful, Cobian will include changes in next day increment
Best regards, Martin
User avatar
cobian
Site Admin
Posts: 4734
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: Checking the existance of destination directory

Post by cobian »

:OK
--
Luis Cobian
Cobian Backup's creator
Dave999
Posts: 2
Joined: 10 Nov 2023, 10:14

Re: Checking the existance of destination directory

Post by Dave999 »

ira wrote: 13 Nov 2023, 20:26 You might be able to create a batch file with a line like this:
if not exist c:\lists.txt exit 7
and then don't continue backup on error be checking "Cancel the task if some event fails."
Thanks ira. You helped me a lot :APP
If anyone wonders:
Create a file on your network folder (for example \\NAS\NAS.txt)
Create a text file on your computer containing this:

Code: Select all

@echo off
if exist \\NAS\NAS.txt (
	exit 0 
	)
	else (
	exit 7 
	)
Rename this file to "check_NAS.bat" (the extension must be BAT and not TXT).
Right click this file and create a shortcut. Right click the shortcut and change the Run parameter to "Minimazed".
In Cobian Tools-Options-Engine check "Analyze exit code..."
In backup task options Events add "Execute and wait" and choose your "check_NAS.bat.Ink" file.
In the same window check "Cancel the task if some event fails".

You can skip the shortcut creation and execute directly the BAT file but the cmd window can be visible for a few seconds everytime the task starts.

This works for me. Sorry for being a bit primitive. Not everyone is a programmer.
Post Reply