Scheduling Backups with Task Manager and PowerShell

PowerShell script exchange

Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 2:18 pm

I am attempting to setup a backup job in the VEEAM software and then on the weekend have the job run off a powershell scripts run by a scheduled task.

I do this by setting up a job in VEEAM and checking it to run Monday through Friday at 8PM but NOT Saturday or Sunday. I set the "Create synthetic full backups periodically" and check Saturday for this option. However, as mentioned already, I do NOT check for the job to run on Saturday in the schedule part of the job.

Then I setup my powershell script and scheduled task to kick the job off on Saturday and schedule the task to run at 2AM. It seems like VEEAM still runs the job on Saturday at 8PM even though Saturday is NOT checked on the schedule. So my question is this. If Saturday is NOT checked on the schedule part of the job, but it is specified as the day for the synthetic job to run, will it still run at 8PM on Saturday?
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby v.Eremin » Wed Dec 09, 2015 4:21 pm

If Saturday is NOT checked on the schedule part of the job, but it is specified as the day for the synthetic job to run, will it still run at 8PM on Saturday?

Correct.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 5:05 pm

Ok. So what I am trying to accomplish is having a different weekend schedule than weekday. How can I use the method of PowerShell and scheduled tasks to schedule my weekend full backups to run at an earlier time than the weekdays? I assume I need to have Saturday specified at the day for my synthetic fulls to run, but I don't want the VEEAM schedule to run them, I want my scheduled task to run them.
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby v.Eremin » Wed Dec 09, 2015 5:17 pm

Firstly, you need to disable both active and synthetic full backups. Secondly, schedule synthetic full on demand script (the second one) via Task Scheduler to take place at whatever time you want to. Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 5:24 pm

How do I tell the script to run the synthetic or full backups? I have seen the scripts on here that call the backup job, but that just calls the job in the GUI and doesn't specify what type of backup to run.
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby v.Eremin » Wed Dec 09, 2015 5:29 pm

The first script disables both active and synthetic fulls for a given job.

The second script thread does the following:

- Get a job with the specified name
- Enables synthetic full for it
- Set synthetic full to run on the current day
- Starts the job

Being scheduled via Task Scheduler, the second script will give you what you're after.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 5:45 pm

Can you post the script here again? The script I found on here was just simply calling the job to run, none of the rest of what you mention. Thanks!
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby tsightler » Wed Dec 09, 2015 6:16 pm

I think it might be easier to just have a post-job script that runs after each job run and, if it's Friday, changes the next scheduled run time to the weekend schedule, and if it's Sunday, changes it back to the weekday schedule. Or at least just use Windows task scheduler to toggle the scheduled run time back and forth as that script would be super easy, probably one-liner. To me that sounds easier than trying to trigger job runs manually all the time, but perhaps I missed the full use case.
tsightler
Veeam Software
 
Posts: 4843
Liked: 1787 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby v.Eremin » Wed Dec 09, 2015 6:39 pm

I've provided the hyper-link in my second answer. But I can post the scripts here, as well:

First:
Code: Select all
Add-PSSnapin VeeamPSSnapin
$JobOptions = Get-Vbrjob -name "Job name" | Get-VBRJobOptions
$JobOptions.BackupTargetOptions.TransformFullToSyntethic = $False
$JobOptions.BackupStorageOptions.EnableFullBackup = $False
$Job.SetOptions($JobOptions)


Second:
Code: Select all
Add-PSSnapin VeeamPSSnapin
$Job = Get-Vbrjob -name "Name of your job"
$OptionsToSet = $Job | Get-VBRJobOptions
$OptionsToSet.BackupTargetOptions.TransformFullToSyntethic = $True
$OptionsToSet.BackupTargetOptions.TransformToSyntethicDays = (Get-Date).DayOfWeek
$Job.SetOptions($OptionsToSet)
Start-VBRJob -Job $Job
$OptionsToSet.BackupTargetOptions.TransformFullToSyntethic = $False
$Job.SetOptions($OptionsToSet)


Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 7:39 pm

tsightler wrote:I think it might be easier to just have a post-job script that runs after each job run and, if it's Friday, changes the next scheduled run time to the weekend schedule, and if it's Sunday, changes it back to the weekday schedule. Or at least just use Windows task scheduler to toggle the scheduled run time back and forth as that script would be super easy, probably one-liner. To me that sounds easier than trying to trigger job runs manually all the time, but perhaps I missed the full use case.


I'm not good with scripting. Would you or someone be able to provide the one liner for me? I really do just need to adjust the schedule for Saturdays only. So if I could just have my schedule in VEEAM set to do incrementals M-F and then fulls on Saturday, then have a script that would run Saturday at 12:01AM that changed the scheduled time to 2AM, and then a script that would run sometime on Sunday that would change the schedule time back to what I want for M-F that would be great too.
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby tsightler » Wed Dec 09, 2015 8:20 pm 1 person likes this post

Something like this:
Code: Select all
Set-VBRJobSchedule -Job "<Job_Name>" -At "20:00" -Daily

That configures the job to run at 8PM each day. You can also add the "-Days" parameter to get the job to run only on specific days. So, for example, you could create two tasks in task scheduler, one that runs on 1:55AM on Saturday and changes the job to run at 2AM. And then another than runs later that switches it back to the "normal" 8PM schedule. So, for example:

Set job to run Saturday at 2AM:
Code: Select all
Set-VBRJobSchedule -Job "<Job_Name>" -At "02:00" -Daily -DailyKind SelectedDays -Days Saturday


Set job to run Mon-Fri at 8PM:
Code: Select all
Set-VBRJobSchedule -Job "<Job_Name>" -At "20:00" -Daily -DailyKind Weekdays
tsightler
Veeam Software
 
Posts: 4843
Liked: 1787 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Wed Dec 09, 2015 9:19 pm

Thank you for posting these Tom. I will give them a try and if they work I will post to another thread on here where others are trying to do the same thing. So this will just change the time the job runs? And the options of being active full, synthetic full or incremental will go off of what is in the VEEAM job setup already in the software correct?
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby tsightler » Wed Dec 09, 2015 9:30 pm

Right, this is only changing the schedule. It's effectively the same as using the GUI to go to the schedule page in the job wizard and changing the scheduling options there. It will not impact other job settings such a active/synthetic/incremental.
tsightler
Veeam Software
 
Posts: 4843
Liked: 1787 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby foggy » Thu Dec 10, 2015 2:27 pm

cffit wrote:If Saturday is NOT checked on the schedule part of the job, but it is specified as the day for the synthetic job to run, will it still run at 8PM on Saturday?

Just to clarify: it will run, however it will not perform synthetic for the second time a day, it will be a regular incremental run.
foggy
Veeam Software
 
Posts: 15089
Liked: 1110 times
Joined: Mon Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson

Re: Scheduling Backups with Task Manager and PowerShell

Veeam Logoby cffit » Tue Dec 15, 2015 6:18 pm

tsightler wrote:Right, this is only changing the schedule. It's effectively the same as using the GUI to go to the schedule page in the job wizard and changing the scheduling options there. It will not impact other job settings such a active/synthetic/incremental.


Thanks Tom, this is working just as I wanted it to. I'm still frustrated that this capability isn't in the GUI...

Is the backup to tape syntax the same? For instance if I want to reschedule the tape backup job for the weekend to run at a different time than weekdays?

I see I should probably use "Set-VBRBackupToTapeJob" but I don't know the rest of the syntax I'd use.
cffit
Expert
 
Posts: 338
Liked: 33 times
Joined: Fri Jan 20, 2012 2:36 pm
Full Name: Christensen Farms

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests