How do you run a batch file before the backup begins using Reflect scheduled backups?


Author
Message
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: 85K
Aha, indeed there are different defaults for PowerShell -- missed that.  In that case maybe just pre-pend the non-PowerShell settings category names with "VBScript". That will make it implicitly clear that there is no mechanism for applying these settings to BAT files, and also reinforce to users that these "Script" settings pertain to types of scripts that Reflect generates, as opposed to being a place where the user can specify scripts for Reflect to use in its general operations.  It might still be handy to add comments over the settings for extra clarity though, both there and for the PS1 defaults.  And then maybe standardize settings category naming between the Edit Defaults and VBS/PS1 script generation UIs, specifically "Elevation / Vista Elevation" and "Duplicate / Directory Synchronization".

And I totally understand that the solution you're proposing is better for the OP, but while we're on this general subject of these settings I figured it was worth discussing anyway as a quasi-Wish List topic.

Edited 10 August 2017 8:50 PM by jphughan
RAKooistra
RAKooistra
New Member
New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)New Member (12 reputation)
Group: Forum Members
Posts: 7, Visits: 144
Nick - 10 August 2017 9:05 AM
@RAKooistra

Thanks for posting. 

To run a batch file before your backup you need to set up a script per backup definition:  http://knowledgebase.macrium.com/display/KNOW7/Generating+scripts+and+batch+files

This generates a full script, either VBScript or Powershell (don't use DOS .bat in this context) that can be used launch pre and post backup processes. There's a Wizard that'll prompt you you for this. This also involves scheduling the scripts rather than the backup definition.

However, there is a much easier way that will fill fit your requirements better.  In the same folder as your backup definition xml file, create a batch file called:

<definition file name>_before_snapshot_wait.bat

Where 'definition file name' is the same name as your xml file (without .xml). When the backup runs it will execute the bat file prior to the backup starting and wait until it finishes before continuing.   You can also use .vbs or .ps1 rather than .bat if you wish.

More info here: http://knowledgebase.macrium.com/display/KNOW7/Stopping+a+SQL+Server+service+automatically+when+backing+up

Although the above KB is specific to stopping the Windows SQL service the same logic can be used to run any batch file. 

I tried this method as Nick suggested but I found it did not work for me.  My company changed the VPN configuration preventing my work PC from connecting to the backup share on another PC.  I created a DOS batch file to close the VPN connection and named it as required ("All Disks_before_snapshot_wait.bat").  When the backup tried to run, it did not seem to execute the batch file first (leaving the VPN connected) and the backup failed. 

I changed my DOS batch file to a PowerShell script, generated the Macrium backup PowerShell scripts, and scheduled them.  The backup executed successfully.

When using the DOS batch file, Macrium Reflect appeared to try to validate the backup destination location before executing the "before" script and failed because of the VPN block.  I cannot say that for sure though but at least the PowerShell script approach worked out.

For the record, Macrium Reflect is the best backup software for PCs that I have purchased.  It certainly crushes Acronis True Image on all points, especially reliability.
Thank you all.


MrPresident
MrPresident
New Member
New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)
Group: Forum Members
Posts: 14, Visits: 37
Hello,
I thought Reflect is able to run pre/post for EACH job. I don´t need general options for all of my 5 jobs. Each job must have it´s own batch/cmd for pre/post.
How can I do that?

I tried out VBS and add both modified batch files. But when I setup the next job the batch files from the job before were shown.
Do I make something wrong?

As I switched between the jobs, the checkboxes in section "run programs" were checked out.
Why?

Windows 7 / 10
Macrium Reflect Workstation 7.3.5365
ESET Internet Security 14

Edited 3 December 2020 7:53 PM by MrPresident
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: 85K
If you set these settings under Edit Defaults > Scripts, then that will affect the default choices when you choose to create any FUTURE script from an existing definition file.  If you want to run a pre/post application for one specific script generated from one specific definition file, then go to Backup Definition Files, right-click the one you want to build a script for, and select Generate PS (or VBS) Script.  In the wizard that pops up, specify your pre- and/or post-backup applications.  From then on, make sure that any schedules or manual executions are associated with the script, not the definition file.

And if you do NOT want a global default pre- and/or post-application for future scripts, you might want to clear the settings out of Edit Defaults > Scripts.

MrPresident
MrPresident
New Member
New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)
Group: Forum Members
Posts: 14, Visits: 37
jphughan - 3 December 2020 7:57 PM
If you set these settings under Edit Defaults > Scripts, then that will affect the default choices when you choose to create any FUTURE script from an existing definition file.  If you want to run a pre/post application for one specific script generated from one specific definition file, then go to Backup Definition Files, right-click the one you want to build a script for, and select Generate PS (or VBS) Script.  In the wizard that pops up, specify your pre- and/or post-backup applications.  From then on, make sure that any schedules or manual executions are associated with the script, not the definition file.

And if you do NOT want a global default pre- and/or post-application for future scripts, you might want to clear the settings out of Edit Defaults > Scripts.

Thanks for your fast reply.
In the global settings are any options selected....


These view I can see when I edit EVERY job and the boxes are evennot checked.
Ok, but associated with WHAT, WHERE,HOW? The first job has now a .vbs file....
I would suggest to place these function in the advanced options related to the job himself and NOT AS GLOBAL SETTING!!

Windows 7 / 10
Macrium Reflect Workstation 7.3.5365
ESET Internet Security 14

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: 85K
I really don't understand where the confusion is here.  When you go to the Backup Definition Files tab, if you right-click a definition file and select "Generate a VBScript File", a wizard will pop up.  If you specify pre- and/or post-backup programs in that wizard or specify any other settings, then those settings will be applied ONLY to that script you're generating at that point.  And that script will be designed to run ONLY the definition file that you selected when you clicked "Generate a VBScript File".  AFTER the script is generated, you will not be able to go back and modify the settings you saw in that script generation wizard, I presume because Macrium is expecting at least some users to manually customize the script after it's generated, and therefore allowing the script to be updated with a Settings interface later on might risk clobbering those manual customizations that users may have made outside of Reflect.  And that is why these options are not in any sort of "Advanced Options" section.  You only get to specify those settings when you are first generating the script.  If you want to edit the script later, you'll have to do it manually.  But you'll see the script under the VBScript Files tab.

So if you already generated a VBS file for your definition file and didn't specify the pre- and/or post-backup programs at that time, then you'll need to generate a new one.

And again, the settings in your screenshot are not "global" settings.  They are "default" settings.  The difference is that default settings simply pre-populate the script wizard with the settings configured under Edit Defaults -- but you can change them.  A global setting would be a setting that applies to all scripts even AFTER they are created.  That is not how Edit Defaults works.  The only reason to change settings under Edit Defaults > Scripts as you showed would be if you generated a lot of scripts and often wanted the same settings to be set by default every single time in order to save you some time generating them.  But changes made there would NOT affect any existing scripts.  It's not a "policy".  It's just a convenience for some people who might otherwise need to specify the same settings repetitively.

It might help for you to read Reflect's online manual.  Macrium's documentation is better than most.  You can access it from the Help menu within Reflect.

Edited 4 December 2020 2:18 PM by jphughan
MrPresident
MrPresident
New Member
New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)
Group: Forum Members
Posts: 14, Visits: 37
jphughan - 4 December 2020 2:06 PM
I really don't understand where the confusion is here.  When you go to the Backup Definition Files tab, if you right-click a definition file and select "Generate a VBScript File", a wizard will pop up.  If you specify pre- and/or post-backup programs in that wizard or specify any other settings, then those settings will be applied ONLY to that script you're generating at that point.  And that script will be designed to run ONLY the definition file that you selected when you clicked "Generate a VBScript File".  AFTER the script is generated, you will not be able to those these settings within Reflect later on, I presume because Macrium is expecting at least some users to manually customize the script after it's generated, and therefore allowing the script to be updated with a Settings interface going forward might risk clobbering those manual customizations that users may have made outside of Reflect.  And that is why these options are not in any sort of "Advanced Options" section.  You only get to specify those settings when you are first generating the script.  If you want to edit the script later, you'll have to do it manually.  But you'll see the script under the VBScript Files tab.

It might help for you to read Reflect's online manual.  Macrium's documentation is better than most.  You can access it from the Help menu within Reflect.
The thought behind pre was to be sure that all older files will be purged and not be twice. If "purge" does the same, I don´t need my batch here.
The thought behind post was that the backup file will be copied to my NAS after the backup has been completed (does not worked)
In both cases the batch file execution (means the DOS box or maybee shell) should be in front so I can see if the execution really works....
---
Another question: how can I disable the scheduler without lost the settings? I can only add, edit or delete, but not simply disable to enable a job later on with same settings....


Windows 7 / 10
Macrium Reflect Workstation 7.3.5365
ESET Internet Security 14

Edited 4 December 2020 3:03 PM by MrPresident
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: 85K
If you want to copy backups to a NAS, just use the Directory Synchronization option that's also listed in the script wizard options.  It's there for that specific purpose.  Although if you want to do that as a scheduled backup, then you'll need to configure scheduled backups to run as a user account that has write access to the NAS share.  By default, Reflect backups run as the local SYSTEM account, which has no access to network resources unless you open up your NAS to anonymous write access, which would obviously be a bad idea.  That might be the problem with your current setup too.  But you don't need to write your own solution for that.

To disable a schedule, go to the Scheduled Backups tab way on the right, right-click the job(s) you want to disable, and click Disable.

MrPresident
MrPresident
New Member
New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)New Member (15 reputation)
Group: Forum Members
Posts: 14, Visits: 37
jphughan - 4 December 2020 4:04 PM
If you want to copy backups to a NAS, just use the Directory Synchronization option that's also listed in the script wizard options.  It's there for that specific purpose.  Although if you want to do that as a scheduled backup, then you'll need to configure scheduled backups to run as a user account that has write access to the NAS share.  By default, Reflect backups run as the local SYSTEM account, which has no access to network resources unless you open up your NAS to anonymous write access, which would obviously be a bad idea.  That might be the problem with your current setup too.  But you don't need to write your own solution for that.

To disable a schedule, go to the Scheduled Backups tab way on the right, right-click the job(s) you want to disable, and click Disable.

I test it with the first job and it works.
After running the second job suddenly all backup files were synchronized....
What about .xml and .vbs, do they not synchronized?
Afterwards I checked in each job these option, they are blank.

Disabled scheduled jobs should be displayed in the backup definition, it would be more clear related to a better overview.
Thanks for help :-)

Windows 7 / 10
Macrium Reflect Workstation 7.3.5365
ESET Internet Security 14

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: 85K
Yes, directory synchronization syncs all backups.  So if old backups get purged or consolidated, those changes will be replicated as well.  The XML and VBS files do not synchronize, and it is a bad practice to store those files with your backups. That is why the default location for those files is a Reflect folder in your user profile's Documents folder.

I don't understand what you mean that "afterwards you checked in each job these option, they are blank".  The pre- and post-backup programs and the directory synchronization options are only available while initially creating the script.  There is no way to go back and check them later.  If you right-click the definition file and select "Generate VBScript File" again, you would be generating a brand new script, not editing an existing script.  Again, I would strongly recommend that you read some documentation here.

Edited 4 December 2020 6:06 PM by jphughan
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