Copy Backup file Issue


Author
Message
was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
I have a strange issue with using bat\cmd scripts in the 'Powershell Script Generation Options'>'Run a program or script at the end' option to copy the Full backup file to a network folder. I use a .bat script to call a .cmd script which contains the following Robocopy command:

robocopy "j:\PowerBoy Images" "\\LINKSYS19381\LaCie\PowerBoy Images" "*Powerboy Main Backup*.mrimg" /COPYBigGrinT /fft

This works fine when running the backup .ps1 script manually from within Macrium Reflect Workstation and the backup file is copied to the "\\LINKSYS19381\LaCie\PowerBoy Images" network folder as expected. However, when the backup is run automatically by the Backup Schedule, this doesn't work and the backup file is not copied. When running the .bat script in W11, again the file is copied correctly.

Very strange. Does anyone have any ideas why this happens?

Andrew
Dan Danz
Dan Danz
Macrium Hero
Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)Macrium Hero (2.7K reputation)
Group: Forum Members
Posts: 1.2K, Visits: 9.5K
was - 9 July 2022 12:16 PM
I have a strange issue with using bat\cmd scripts in the 'Powershell Script Generation Options'>'Run a program or script at the end' option to copy the Full backup file to a network folder. I use a .bat script to call a .cmd script which contains the following Robocopy command:

robocopy "j:\PowerBoy Images" "\\LINKSYS19381\LaCie\PowerBoy Images" "*Powerboy Main Backup*.mrimg" /COPYBigGrinT /fft

This works fine when running the backup .ps1 script manually from within Macrium Reflect Workstation and the backup file is copied to the "\\LINKSYS19381\LaCie\PowerBoy Images" network folder as expected. However, when the backup is run automatically by the Backup Schedule, this doesn't work and the backup file is not copied. When running the .bat script in W11, again the file is copied correctly.

Very strange. Does anyone have any ideas why this happens?

Andrew
What was the precise error message when it failed? Could it be that the scheduled backup is set to run as System, but you haven't provided a valid login to the backup location in the Defaults>Network Share Settings?



L.W. (Dan) Danz, Overland Park KS
Reflect v8.1.7847+ on Windows 11 Home 23H2 22631.3085+ | Reflect v8.1.7853+ on Windows 10 Pro 22H2 19045.3996+
Reflect v8.1.7784+ on 2 systems Windows 10 Home 22H2 19045.3803+

was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
L. W. "Dan" Danz - 9 July 2022 2:37 PM
was - 9 July 2022 12:16 PM
I have a strange issue with using bat\cmd scripts in the 'Powershell Script Generation Options'>'Run a program or script at the end' option to copy the Full backup file to a network folder. I use a .bat script to call a .cmd script which contains the following Robocopy command:

robocopy "j:\PowerBoy Images" "\\LINKSYS19381\LaCie\PowerBoy Images" "*Powerboy Main Backup*.mrimg" /COPYBigGrinT /fft

This works fine when running the backup .ps1 script manually from within Macrium Reflect Workstation and the backup file is copied to the "\\LINKSYS19381\LaCie\PowerBoy Images" network folder as expected. However, when the backup is run automatically by the Backup Schedule, this doesn't work and the backup file is not copied. When running the .bat script in W11, again the file is copied correctly.

Very strange. Does anyone have any ideas why this happens?

Andrew
What was the precise error message when it failed? Could it be that the scheduled backup is set to run as System, but you haven't provided a valid login to the backup location in the Defaults>Network Share Settings?


Thanks for the reply. There is no error message, the robocopy command just doesn't work. Your point about providing a valid login : As the network connection exists, I have left the default blank. In any case, I presume that the network connection should be found or not found irrespective of whether the backup in initiated manually or automatically? I'll set 'Enable anonymous logon for all share connection attempts' to true and see if that makes any difference.
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
For reasons primarily related to security, authenticated network connections in Windows are per-context, and Windows runs scheduled tasks in a separate context from that of the logged-in user.  The result is that having an open network connection in your user session does absolutely nothing for Reflect jobs (or in your case, a Reflect script) that was started in the context of a background scheduled task, even though that open network connection would be perfectly usable if you started a Reflect job or that script in your local user context.  You'll need to modify your CMD script to open an authenticated network connection (and optionally close it afterward).

Also, you appear to be conflating BAT, CMD, and PowerShell script types.  You say you have a BAT file, but refer to "PowerShell Script Generation Options".  Reflect-generated BAT files don't have a field for the post-backup application, so it sounds like you are in fact using PowerShell, but for the sake of clarity, it would be good not to mix those terms up.

Edited 10 July 2022 12:42 AM by jphughan
was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
Thanks, that explains it. I'll make the appropriate changes to the cmd script. Yes, I am using a Powershell script to run the 'Run a program or script at the end' option using the bat script - which in turn calls the cmd script with the Robocopy command. Sorry I did not make that clearer - the issue  is quite complicated to describe!

Thanks again.
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
So you have a Reflect-generated PowerShell script, which calls a BAT file after backups, and then the BAT file itself calls some other CMD file?  All just to copy some files?  That is unnecessarily complicated.  In fact the Reflect script-generation wizard even has a "Synchronize directories" option section that sounds like it would do exactly what you wanted -- unless you're trying to copy ONLY Full backups to the destination?  But otherwise, using that option would get you the necessary functionality built right into the PowerShell script, except that you would have to customize that PowerShell to script to add the command to open the network connection first before Reflect attempted to copy files to that location.  But that's pretty easy to do if you want to go that route, and you'd then have what you needed in a single script rather than split across three scripts.

was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
Yes, that's correct. I am only copying Full backups to two separate network folders. I'll have a look at 'Synchronize directories' and see if that would do the job and simplify the process.

Thanks for the suggestion.
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
Unless you're only creating Full backups, then Synchronize Directories won't work for your purposes, since that will replicate all Reflect backups in the destination folder over to the replication destination you specify, not just Full backups.

was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
Well, I am only creating Full backups, so that's not a problem. However, I'm using the cmd script to copy backups to a couple of internal folders in addition to the two network folders, so I'm not sure Synchronize Directories will be useful in my case. Although, perhaps I could amend the generated Powershell script to handle multiple copy actions?
was
was
New Member
New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)New Member (28 reputation)
Group: Forum Members
Posts: 13, Visits: 110
As you suggested, I tried to open an authenticated network connection in the cmd script before the Robocopy backup file copy command as follows:

net use \\LINKSYS19381\Samsung_T7_2TB
robocopy "J:\Powerboy Images" "\\LINKSYS19381\Samsung_T7_2TB\PowerBoy Images" "*Working Files Backup*.mrbak" /COPYBigGrinT /fft

but it doesn't make any difference; the backup file is copied successfully to the local  folders but not to the network ones. I have also tried adding network credentials for my router shares in the 'Network Logon credentials for Server Shares, but that doesn't work as there is an existing network connection. Am I using the correct net command?
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