Comprehensive data protection for all workloads
Post Reply
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Hello,

Create a support case (01857778), they told me to post here because I was scripting the job run. This seems like an actual issue with the backup copy job interval timer not working properly, like it's not being correctly accounted for when the backup copy job is executed from PowerShell. Everything was working great with a similar script (which I had built with suggestions from other posts on this forum) before I had reworked my jobs, so I could have mis-configured something. Anyhow, original support request is below (with some added clarifying text):
I've recently reworked my backup and backup copy jobs, and have 4 backup copy jobs that are set to copy every 7 days so I can perform GFS retention on our primary vault. To do this correctly, I have a Windows scheduled task that executes every day, which could execute 1 of the 4 backup copy jobs any given day throughout the week.

Here's the script:

Code: Select all

Add-PSSnapin VeeamPSSnapin

$Today = (get-date).DayOfWeek.ToString().ToLower()

Switch ($Today) {
"monday" { Sync-VBRBackupCopyJob -Job (Get-VBRJob -Name "Daily_VMs_M-F_GFS_Vault1") }
"wednesday" { Sync-VBRBackupCopyJob -Job (Get-VBRJob -Name "Daily_TFS_M-F_GFS_Vault1") }
"saturday" { Sync-VBRBackupCopyJob -Job (Get-VBRJob -Name "Weekly_TFS_Sat_GFS_Vault1") }
"sunday" { Sync-VBRBackupCopyJob -Job (Get-VBRJob -Name "Weekly_VMs_Sun_GFS_Vault1") }
}
This script works great, but I'm finding that all 4 backup copy jobs are all executing on Tuesday in addition to the days I specify in the script. Before I reworked the jobs, the 7 day copy interval would be reset based on when the script executed, so all the jobs were properly staggered. Now they're staggered and all executing on Tuesday on top of that, so the calls from PowerShell don't seem to be resetting the timer interval.

Can I get someone to verify that my jobs are all configured correctly?

Thank you,
Dan
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by veremin »

Before we proceed to code discussion, can you tell what is your underlying goal? What are trying to achieve by using multiple backup copy jobs? May be we can propose a different scenario to you. Thanks.
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Hi v.Eremin,

I've got 4 backup jobs that keep a few weeks of restore points on our primary vault server. My goal with the backup copy jobs is to perform GFS retention on the primary vault server beyond the few weeks the backup job provides. The 4 backup copy jobs are scheduled to run after the backup jobs perform full active backups. I'm also performing backup copys for the same backup jobs to our secondary vault server, but it runs daily to ensure we have restore points available offsite (in addition to the GFS retention it performs).

I never considered having one backup copy job perform GFS retention for the 4 backup jobs; is it preferred for any reason?

Thank you,

Dan
foggy
Veeam Software
Posts: 21139
Liked: 2141 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by foggy »

It's just the matter of jobs management, you can do it either way.
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Alright, sounds okay to me. By having separate jobs, I'm able to reduce overall I/O since I'd be executing each job only once a week.

Any additional thoughts as to why the 7-day job interval timer would still execute on Tuesday if it should be reset by the PowerShell script on some other day during the week?
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by veremin »

I never considered having one backup copy job perform GFS retention for the 4 backup jobs; is it preferred for any reason?
In my opinion, it would be a preferable option, as not only would that guarantee easier management, but also it would allow you to get rid of scripts.

Also, since backup copy job is not about direct copying mechanism, there is no need to synchronize its cycle with an active full pass of primary backup job.

Thanks.
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Also, since backup copy job is not about direct copying mechanism, there is no need to synchronize its cycle with an active full pass of primary backup job.
Is there another mechanism available for creating a direct copy and performing retention on a set of backups? Creating a backup copy job to facilitate GFS retention and executing it after a full backup was the closest I could get.
foggy
Veeam Software
Posts: 21139
Liked: 2141 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by foggy »

It is a correct mechanism, if you need the backup copy to copy the latest VM state right after the source backup job has completed, you need to schedule it with a short delay after the backup job starts. It will wait for the backup job completion and start copying data right away.
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Hi foggy,

What you're describing is what I've configured the jobs to do. I'm only looking to execute these backup copy jobs after an active full backup is performed for their corresponding backup jobs, which is done once a week for any backup job. In turn, the backup copy job interval is set to 7 days. The backups are finished at least an hour before the backup job is scheduled to copy the latest available data around 11:30 PM.

My PowerShell script executes as expected and runs the backup copy jobs on either Monday, Wednesday, Saturday, or Sunday. For some reason, the backup copy jobs all run on their own on Tuesday as well, even though some of them don't have any new data to copy.

Whether or not the copy job is called from PowerShell, the copy interval should be reset, it just doesn't seem to be!

Dan
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Got the assistance I needed with support, posting in case future searches bring up this issue for other users.

Here's a back and forth I had with a configuration support tech:

Support:
After reading through the case this is the conclusion that I have came to:

Your Backup Copy Job should be disabled. After your full backup runs you should have a post job script that enables it. Then have a post job script on the Backup Copy Job that disables it.

This should get the BCJ to only run once and not twice. As of now, with what I have read, it is working as intended, the way that you have it set.
Me:
Can you elaborate a little on how this is working as intended? It sounds like Tuesday is the day I had initially created and enabled the backup copy jobs, so this is when the synchronization interval was set to? The script calling a Sync-VBRBackupCopyJob doesn't reset this interval then?

In any case, if your recommendation is to enable and disable the backup copy job through post job scripts, I'm more than happy to implement that solution. I appreciate your feedback, and feel comfortable closing this case.
Support:
No problem, it is causing a "forced sync" which doesn't reset the interval, it simply tells it to do another sync within that interval. So even though it is syncing on the fulls, it is still on the Tuesday interval.


And here are scripts I'm using to enable my backup copy jobs after the last backup occurs and disable my backup copy jobs after the backup copy job has run:

Enable (had to account for backup jobs running past midnight; also, probably not the most efficient way, but works well):

Code: Select all

Add-PSSnapin VeeamPSSnapin

$Day = (get-date).DayOfWeek.ToString().ToLower()
$AMPM = (get-date).DateTime.ToString().ToLower()

If ($AMPM.Contains("pm"))
{
Switch ($Day)
{
"tuesday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_2_Month_Retention_job1_Vault1") }
"wednesday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_2_Month_Retention_job2_Vault1") }
"thursday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_1_Year_Retention_Vault1") }
"friday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_1_Year_Retention_Vault1") }
"saturday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_2_Month_Retention_job1_Vault1") }
"sunday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_2_Month_Retention_job2_Vault1") }
}
}
ElseIf ($AMPM.Contains("am"))
{
Switch ($Day)
{
"wednesday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_2_Month_Retention_job1_Vault1") }
"thursday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_2_Month_Retention_job2_Vault1") }
"friday" { Enable-VBRJob -Job (Get-VBRJob -Name "VMs_1_Year_Retention_Vault1") }
"saturday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_1_Year_Retention_Vault1") }
"sunday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_2_Month_Retention_job1_Vault1") }
"monday" { Enable-VBRJob -Job (Get-VBRJob -Name "TFS_2_Month_Retention_job2_Vault1") }
}
}

Disable (since none of my jobs should be enabled after any particular run, I check to disable all of them):

Code: Select all

Add-PSSnapin VeeamPSSnapin

$BackupCopyJobs = @("VMs_2_Month_Retention_job1_Vault1","VMs_2_Month_Retention_job2_Vault1","VMs_1_Year_Retention_Vault1","TFS_1_Year_Retention_Vault1","TFS_2_Month_Retention_job1_Vault1","TFS_2_Month_Retention_job2_Vault1")

ForEach ($BackupCopyJob in $BackupCopyJobs)
{
If ((Get-VBRJob -Name $BackupCopyJob).IsScheduleEnabled)
{
Disable-VBRJob -Job (Get-VBRJob -Name $BackupCopyJob)
}
}

Also, I didn't find any recommendations for running PowerShell scripts post job run since it's not officially supported. Below is the string I've used to call my script using PowerShell and force it to run as administrator:

Code: Select all

Powershell.exe -Command "Start-Process -FilePath powershell.exe -Argument C:\cmd\Veeam_GFS_Vault1_Disable.ps1 -Verb RunAs"
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by veremin »

Also, I didn't find any recommendations for running PowerShell scripts post job run since it's not officially supported.
Could you elaborate on "officially not supported" portion?
Below is the string I've used to call my script using PowerShell and force it to run as administrator:
May I ask you why instead of your current approach you don't grant required permissions to Veeam service account and use the following line as a post-job activity?

Code: Select all

Powershell.exe -File "C:\cmd\Veeam_GFS_Vault1_Disable.ps1"
Thanks.
danielch
Influencer
Posts: 15
Liked: 2 times
Joined: Sep 04, 2015 3:08 pm
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by danielch »

Hi v.Eremin,
Could you elaborate on "officially not supported" portion?
Looks like I misinterpreted a response from this thread: powershell-f26/running-veeam-powershell ... 26328.html

Specifically this response:
Yep, both pre and post job commands should be batch. But there is nothing preventing you from triggering PS scripts from a batch. Thanks.
I took that to mean .bat or .cmd files, and the Veeam engine is calling any commands using the Windows cmd. The end result being I can't just list "C:\cmd\Veeam_GFS_Vault1_Disable.ps1" in the post-job script field, but have to explicitly call PowerShell to perform the action, unlike being able to call "C:\cmd\Veaam_Script.cmd" in the post-job script field. In that sense, is PowerShell not directly supported? Didn't meant to speak on behalf of Veeam for that.
May I ask you why instead of your current approach you don't grant required permissions to Veeam service account and use the following line as a post-job activity?
The only reason I used the PowerShell command string I provided was to avoid any unforeseen problems, particularly with UAC being enabled on the server. The Veeam service account is a local administrator, so it likely wouldn't have been a problem. Since I hadn't seen anyone else try calling PowerShell with the RunAs parameter being passed, I figured I'd give it a try and have it as an alternative to the command string you provided. It's been working as intended so far.

Let me know if you have any other questions!

Dan
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Copy Jobs, PowerShell, Copy Interval Timer Issue

Post by veremin »

Looks like I misinterpreted a response from this thread:
After having reviewed my original answer, I have to tell you that I find it a bit incomplete. I meant to say only batch and executable files are supported for pre and post job activity.

Which means you can easily the construction where you specify PowerShell.exe as an executable and provide it with a path to a script it should run.
The only reason I used the PowerShell command string I provided was to avoid any unforeseen problems, particularly with UAC being enabled on the server. The Veeam service account is a local administrator, so it likely wouldn't have been a problem. Since I hadn't seen anyone else try calling PowerShell with the RunAs parameter being passed, I figured I'd give it a try and have it as an alternative to the command string you provided. It's been working as intended so far.
Sure, your approach should also work smoothly. So, feel free to leverage it.

Thanks.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 126 guests