Using a Batch File to run a backup job


Author
Message
David Faithfull
David Faithfull
New Member
New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)
Group: Forum Members
Posts: 5, Visits: 9
Hi. I created a job to clone a disk, and scheduled this to run every week. Works fine; but I wanted to automatically copy a file to the clone once the job had completed. So I got Macrium to create a batch file from the definition, which I then added my specific commands to. If I run the batch file manually it all works perfectly - but how do I get Macrium to schedule and run the batch file, rather than the associated xml file, which it runs by default? I am probably being stupid, but please humour (and assist) me!
Many thanks in advance.

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
If you used Reflect to generate the batch file, then it should be under the Scripts tab (in V8) or the MS-DOS Files tab (in V7). Either way, right-click that and select Schedule, then set your schedules up. Then remove your schedules from the XML file.

And fyi if you had chosen to use a PS or VBS file, the script generation wizard would have included additional sections of options, including one to specify pre- and/or post-job applications to run. Batch files are the least functional option.
David Faithfull
David Faithfull
New Member
New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)
Group: Forum Members
Posts: 5, Visits: 9
Hi. Thanks for that: interestingly, I checked, and I had done that - the batch file was scheduled, the xml  file was not. I have deleted all schedules and re-scheduled everything again: time to wait and see what happens!
I will report back...

David Faithfull
David Faithfull
New Member
New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)
Group: Forum Members
Posts: 5, Visits: 9
Hi. Nope, it still doesn't work. I know that using a batch file is inflexible and even 'crude' - but (if it worked!) it suits my purposes. And not being an expert in batch file processing, I may have missed something that is 'obvious' to you!
The batch file is scheduled to run; and, as I confirmed, the xml file isn't.
Here's the start of the batch file (which is just Macrium's template):
@echo off
REM ******************************************************************************
REM *
REM *
REM * Module Name: MACRIUM - Clone C to E.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
"C:\Program Files\Macrium\Reflect\ReflectBin.exe" -e -w -full "C:\Users\David Lamont\Documents\Reflect\MACRIUM - Clone C to E.xml" -g
if ERRORLEVEL 3 goto busy
if ERRORLEVEL 2 goto validation_error
if ERRORLEVEL 1 goto backup_error
if ERRORLEVEL 0 goto ok

... and here's the end (the bits that I have added):
:ok
rem ========================================================
ECHO OFF
cls
echo .
echo .......................................
echo .
echo Clone has completed.
echo --------------------
echo .
echo A text file will now be created to identify the date/time the clone was done.
echo - the system date and time will be written to the file automatically.
echo .
echo .
echo .
e:
cd Users\David Lamont\Documents
if exist E:\Users\"David Lamont"\Documents\~CloneDONElast.txt del E:\Users\"David Lamont"\Documents\~CloneDONElast.txt
echo %date% %time% >> E:\Users\"David Lamont"\Documents\~CloneDONElast.txt
echo .
echo .
echo .
echo Done! File ~CloneDONElast.txt contains the date/time when this clone was done.
echo .
echo .
TIMEOUT /T 10
goto finish
:end
echo There was an error... clone not completed.
pause

:finish
It seems that the batch file runs and executes the xml file, but then isn't resumed afterwards.
Any ideas? I'll be extremely grateful for your assistance and advice.

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
Does the batch file run as expected if you open an elevated Command Prompt and run it that way?  If you haven't already, you should ALWAYS verify successful execution in an interactive context before moving to running it as a background scheduled task.

Also, when posting the contents of scripts, it's useful to use a code block, which causes the contents to be displayed in fixed width font and disables auto-formatting such as converting certain character sequences to smileys.  Here is an example:

This text is in a code block
See how it looks different?


jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
One quick note.  You may want to change your "CD" command to include the /D switch to allow it to switch drive letters if needed.  If you're on C and you enter "CD E:", you won't switch to E.  If you enter "CD /D E:", you will.

David Faithfull
David Faithfull
New Member
New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)
Group: Forum Members
Posts: 5, Visits: 9
Thanks!
I put in the /D switch as you suggested, and yes, I had run the batch file interactively to check it. But I then spotted this in the script:

cd /D E:Users\David Lamont\Documents
if exist E:\Users\"David Lamont"\Documents\~CloneDONElast.txt del E:\Users\"David Lamont"\Documents\~CloneDONElast.txt

I had forgotten the quotes around the user name! Presumably as that would have generated an error the batch process was aborted?
Put them in, and it works fine interactively. Now I'll wait until tomorrow's scheduled run and check it works then.
Thanks for your help and tips!
David

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
Ah yes, and looking at that now, the more common syntax would be to encase the entire path in quotes if there’s a space, rather than only doing that around the folder name that contains a space. But if it works, it works! Smile
David Faithfull
David Faithfull
New Member
New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)New Member (6 reputation)
Group: Forum Members
Posts: 5, Visits: 9
Hi.
Just to say many thanks again. Even though it was me who spotted the fault, your knowledgeable comments, advice and suggestions certainly helped in the process of fault-finding!
This evening at 7pm is when it is scheduled to run automatically - you'll hear from me again in the (unlikely, I think) event that it doesn't work!
Best wishes, take care and keep up the good work.
David

jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
Happy to help, and glad you've gotten what you needed.  Enjoy! Smile

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Login

Explore
Messages
Mentions
Search