Help with Batch file running backups


Author
Message
MaxLVB
MaxLVB
New Member
New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)
Group: Forum Members
Posts: 7, Visits: 30
I use a batch file generated by Macrium Reflect to make full file/folder backups and Drive Image backups of all drives once a week.
The Batch file runs the file/folder backup first then should run the Drive Image backup next. I'm using a batch file on the KISS principle, and because I don't know enough about VBscripting or Powershell programming to do it that way.

When I first ran the batch file Macrium popped up the window saying the backup was about to start, and I ticked the 'Do Not Show This Message Again' option.
This happened again when the file/folder back finished, and the Drive Image backup was about to start. Again I ticked 'Do Not Show' option again.

The pop up message no longer appears, but once the file/folder backup has finished, Macrium still requires a key press or mouse click to start the Disk Image backups.
I have checked all the Macrium backup options and cant see anywhere why this happens.

As I want to run this batch file overnight, does anyone know why Macrium still requires a key press or mouse click, and is there anything I can put in the batch file to do this or stop it happening?

This is the batch file:

@echo off
REM ******************************************************************************
REM *
REM *
REM * Module Name: Cray-1 Daily Backup.bat
REM *
REM * Abstract:  This is a template MSDOS batch file generated by Reflect v6
REM *      Modify to add your own functionality if required
REM *
REM *
REM ******************************************************************************

:again
"D:\Backup Utils\Reflect\ReflectBin.exe" -e -w -full "E:\Computer\Macrium Reflect\Scripts\Cray-1 Daily Backup.xml" -g

if ERRORLEVEL 3 goto busy
if ERRORLEVEL 2 goto validation_error
if ERRORLEVEL 1 goto backup_error
if ERRORLEVEL 0 goto ok

:busy
REM Will never get here if '-w' switch is used
echo A backup or restore operation is in progress
goto again

:backup_error
REM User cancelling a backup or any other error
echo A Backup error has occurred
goto end

:validation_error
REM Command line or XML syntax errors
echo A validation error has occurred
goto end

:ok
echo ok!
goto ImageBackup

                                   (** Macrium waits for the key press or mouse click here**)

@echo off
REM ******************************************************************************
REM *
REM *
REM * Module Name: Images Backup.bat
REM *
REM * Abstract:  This is a template MSDOS batch file generated by Reflect v6
REM *      Modify to add your own functionality if required
REM *
REM *
REM ******************************************************************************

:ImageBackup
"D:\Backup Utils\Reflect\ReflectBin.exe" -e -w -full "E:\Computer\Macrium Reflect\Scripts\Images Backup.xml" -g

if ERRORLEVEL 3 goto busy
if ERRORLEVEL 2 goto validation_error
if ERRORLEVEL 1 goto backup_error
if ERRORLEVEL 0 goto ok

:busy
REM Will never get here if '-w' switch is used
echo A backup or restore operation is in progress
goto again

:backup_error
REM User cancelling a backup or any other error
echo A Backup error has occurred
goto end

:validation_error
REM Command line or XML syntax errors
echo A validation error has occurred
goto end

:ok
echo ok!
goto end

:end
shutdown -s

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)
Group: Forum Members
Posts: 4.2K, Visits: 30K
You shouldn’t have two jobs run in the same batch file, because if the jobs have different outcomes, you won’t be able to tell which one failed based on the exit code of the batch file. Another problem in your current batch file design is that the second backup job will only ever run if the first one succeeds, which you may not want. And a third issue is that your image backup’s “Busy” section says “goto Again”, which means if the batch file ever ends up there, it would try to run the F&F backup job again instead of the image job. That should say “goto ImageBackup” instead. Granted that may never matter since the comment says it will never end up there when the -w parameter is used to call Reflect, but it’s not ideal.

But if you just want your two jobs to run back to back, create a separate batch file for each job and schedule them one minute apart from each other. When a scheduled job is called while an existing job is already running, Reflect queues the second job and runs it as soon as the existing job finishes. Or actually, if the sole reason you’re using a batch file is because you wanted to run two jobs in the same batch file, then you can KISS to an even greater degree by abandoning batch files entirely. Just create schedules associated with the XML backup definition files themselves.
Edited 31 December 2018 7:06 AM by jphughan
MaxLVB
MaxLVB
New Member
New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)New Member (9 reputation)
Group: Forum Members
Posts: 7, Visits: 30
Thanks for your quick reply...

> You shouldn’t have two jobs run in the same batch file, because if the jobs have different outcomes, you won’t be able to tell which one failed based on the exit code of the batch file

I dont use the batch file to check for success/failures. I always check the Macrium Reflect log.

> Another problem in your current batch file design is that the second backup job will only ever run if the first one succeeds

This is what I want to happen. I need/want to check any cause of a failure in the Macrium log before running any more backups.

> And a third issue is that your image backup’s “Busy” section says “goto Again”, which means if the batch file ever ends up there, it would try to run the F&F backup job again instead of the image job. That should say “goto ImageBackup” instead.

Thanks for pointing out that error. Fixed.

> But if you just want your two jobs to run back to back, create a separate batch file for each job and schedule them one minute apart from each other. When a scheduled job is called while an existing job is already running, Reflect  queues the second job and runs it as soon as the existing job finishes. Or actually, if the sole reason you’re using a batch file is because you wanted to run two jobs in the same batch file, then you can KISS to an even greater degree by abandoning batch files entirely. Just create schedules associated with the XML backup definition files themselves.

The reason I'm not using a schedule to run these backups is that I have no set time that I start the backups. I usually start them very early on Friday morning (just after midnight Thursday for both my computers) before I go to bed, and as the both backups take about 2-3 hours to complete they need to be finished before 4 am when my router has a daily scheduled reboot. If that happened in the middle of the backups the NAS the backups are going to would suddenly become unavailable.

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)Macrium Evangelist (6.1K reputation)
Group: Forum Members
Posts: 4.2K, Visits: 30K
Ok, I just tried to reproduce this behavior on my own system using your batch file and couldn't.  The only thing I changed was the paths to ReflectBin and the definition file to values that are appropriate for my system.  I then tried running the batch file by right-clicking the batch file and selecting open, calling it from an open Command Prompt, and calling it from an open elevated Command Prompt, I never had to do anything .  In the first two cases I had to acknowledge a UAC prompt before each job, but that was it.  In the elevated Command Prompt case, it ran as expected, o I'm not sure why your system is behaving differently.  I'm still running Reflect 7.2.3906 if that matters, but I doubt it.

However, one other thing you may also want to fix anyway is that combining two original batch files has caused your batch file to reuse label names in multiple places, specifically busy, backup_error, validation_error, and ok.  That can lead to unexpected behavior when those are referenced by "goto" statements, so you might want to fix that.  Sorry I can't offer any insight into the key press issue though!

Edited 31 December 2018 4:35 PM by jphughan
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search