Post backup program not run if backup scheduled


Author
Message
aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
Hello,
I'm encountering problem with running program that should to run after backup is done. I read topics https://forum.macrium.com/Topic21470.aspx and https://forum.macrium.com/Topic24025.aspx but changing creditials doesn't help to me. Here is detailed description of my situation:
I'm using Macrium Reflect 7.2 Home Edition 64bit in Windows 10 Pro. I have created VBScript for defined file and folder backup (defined in XML). After backup done I need to have executed batch created by me. For this reason in option Run Programs I provided link to my batch and checked option "Run a program or script at the end.". Behaviour is following - when I run VBScript manually (no matter if by shortcut from desktop or by Run Now command in Macrium Reflect user interface from VBScript Files) it works correctly. This means that after backup is my batch executed. When I create schedule for this VBScript then backup is done correctly but my batch that should be executed after backup done is not executed. Of course I also tested my batch separately and its work correctly.
In accordance with 2 above mentioned topics I done required change. This means that in Other Tasks -> Edit Defaults (Refect Defaults) -> Schedule -> Schedule User -> Check box (Use the Windows SYSTEM account to run scheduled tasks) I unchecked and provided my account (with administrator rights of course) user name and password. But it doesn't help (I also done computer reset after this setup). I also tried to create user account only for purpose of Macrium Reflect scheduled task executions but this also doesn't help.
It looks like Macrium Reflect is still using SYSTEM creditials for scheduled backup executions. I don't know, I don't have idea where can be problem.

Does anybody have idea how to solve that problem, please?

Thanks


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
What does your batch file do? Scheduled tasks run in the background, and not all applications support running that way. Just as a test, try a batch file that involves a simple task, such as copying a text file from one folder to another. If that batch file works after your backup even when it is a scheduled backup, then the problem is not Reflect. It is something about what you are trying to do in your batch file.
aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
jphughan - 21 September 2019 2:28 PM
What does your batch file do? Scheduled tasks run in the background, and not all applications support running that way. Just as a test, try a batch file that involves a simple task, such as copying a text file from one folder to another. If that batch file works after your backup even when it is a scheduled backup, then the problem is not Reflect. It is something about what you are trying to do in your batch file.

Sorry, I forgot to wrote that one of my tests included replace my batch by starting of any program. But it was same - program not runs after backup finish.
But in any case here is list of my batch:

@ECHO OFF
ECHO Creating list of new backup files. Please wait.
cd /d z:
forfiles /s /m *.mrbak /d +0 /c "cmd /c echo @path" > Z:\New_backup_files.txt
ECHO Task complete.
pause

Purpose of the batch is simmple - to create list of new mrbak files from Z drive (NAS where I store backups) created today and save it into file New_backup_files.txt

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
The problem is that you’re using a mapped drive. Drive mappings only exist in the user session that created them. So when you were using the SYSTEM account, that account would not have the Z drive mapping that exists in your user session. And even when you change Reflect to use your own account, a task that runs in the background runs in a different context that again doesn’t have access to those drive mappings. You’ll need to expand the batch file to include a “net use” command to actually create the Z drive mapping. If the account that is running the backup does not automatically have access to that network share, you will need to specify a username and password with the “net use” command that has access to the network location, which means storing the password in the batch file.
Edited 21 September 2019 3:06 PM by jphughan
aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
jphughan - 21 September 2019 3:03 PM
The problem is that you’re using a mapped drive. Drive mappings only exist in the user session that created them. So when you were using the SYSTEM account, that account would not have the Z drive mapping that exists in your user session. And even when you change Reflect to use your own account, a task that runs in the background runs in a different context that again doesn’t have access to those drive mappings. You’ll need to expand the batch file to include a “net use” command to actually create the Z drive mapping. If the account that is running the backup does not automatically have access to that network share, you will need to specify a username and password with the “net use” command that has access to the network location, which means storing the password in the batch file.

OK, thanks for explanation, I understand. But problem is that post backup run doesn't work not only with my batch but also with software that is located in system C drive. For purpose of testing I chosen SoftPerfect Network Scanner (software for scanning IP adresses with GUI) located in "C:\Program Files\SoftPerfect Network Scanner\netscan.exe". With that post backup run also doesn't work in case of scheduled run.

In any case I will found how to map NAS as drive by commands in batch (or generally how to access network drive without mapping) and will add to my batch. In meantime I will prepare edited batch that will use any of standard (in means not network, so C, D or F) drives for testing.


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 don't know anything about the application you just mentioned, but as I said some applications don't work when run in the background, so I don't think adding that as another variable will help.  But as I said originally, if you're concerned that the batch file simply isn't being executed, try writing a batch file that performs a simple task, such as copying a file on your C drive to another folder on your C drive, and having Reflect run that after your job.  If even that fails, then yes it seems like the batch file is being ignored entirely.  But it's important to figure out whether the issue is batch files not running at all or YOUR batch file not running as expected.

aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
So, I done tests with edited batch that now fully operates on standard SATA attached drive D. I also switched from creditials created specially for Macrium Reflect (because I§m not sure about access rights to all folders etc.) back to my accout creditials. Now batch is:

@ECHO OFF
ECHO Creating list of new backup files. Please wait.
cd /d d:\temp\mrtests
forfiles /s /m *.mrbak /d +0 /c "cmd /c echo @path" > New_backup_files_test.txt
ECHO Task complete.
pause

But with this batch it is same. Still not run after backup when backup is scheduled.

In any case I will need to solve NAS handling in batch. This is one problem. But now there is also some other problem that causes that when backup is scheduled then post backup run not work.

aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
jphughan - 21 September 2019 4:33 PM
I don't know anything about the application you just mentioned, but as I said some applications don't work when run in the background, so I don't think adding that as another variable will help.  But as I said originally, if you're concerned that the batch file simply isn't being executed, try writing a batch file that performs a simple task, such as copying a file on your C drive to another folder on your C drive, and having Reflect run that after your job.  If even that fails, then yes it seems like the batch file is being ignored entirely.  But it's important to figure out whether the issue is batch files not running at all or YOUR batch file not running as expected.

OK, I will try another batch mentioned by you.
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
And fyi, I doubt this will fix the problem, but if you ever want to do what you're trying to do in PowerShell rather than with a batch file, here's the command you would use in a PowerShell script:

(Get-ChildItem -Recurse | where {$_.Extension -eq ".mrbak" -and $_.LastWriteTime -ge (Get-Date).date}).FullName | Out-File New_backup_files_test.txt

Edited 21 September 2019 5:26 PM by jphughan
aleshonsa
aleshonsa
New Member
New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)New Member (33 reputation)
Group: Forum Members
Posts: 27, Visits: 117
I must apologize because in post from 5:40 PM I was wrong. I not saw correctly. In Scheduled Backups table I seen that task was still marked as running. It was too long after backup start, so I thought that post run again failed. But when I looked into target folder I learned that file New_backup_files_test.txt was been created. This situation leaded me to idea that when batch is running on background there can be problem with required user reaction based on pause command. This command requires user to press any key to continue. So I deleted it from my batch and now it is working!

So correct for of batch is:

@ECHO OFF
ECHO Creating list of new backup files. Please wait.
cd /d d:\temp\mrtests
forfiles /s /m *.mrbak /d +0 /c "cmd /c echo @path" > New_backup_files_test.txt
ECHO Task complete.

Probably all ECHO commands are now unnecessary, because there is no any interface showing messages.

So it is now working. Many thanks for your help. Now only remains how to solve access to NAS.

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