-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2009 4:11 pm
- Full Name: Gioachino
- Contact:
Help! How can execute jobs in sequence?
Hi!
I've 7 backup job (one for each VM) scheduled during the night.
At the moment i've scheduled one job every hour, to avoid the overlay of jobs, but i've a lot of time lost because the backup duration is between 20 and 40 minutes.
Is it possible to concatenate the jobs so at the end of first automatically start the second and so on? In this way i don't have loss of time between one job and the next (now i've scheduled one job every hour but i've a lot of time lost).
Thanks,
Gio.
I've 7 backup job (one for each VM) scheduled during the night.
At the moment i've scheduled one job every hour, to avoid the overlay of jobs, but i've a lot of time lost because the backup duration is between 20 and 40 minutes.
Is it possible to concatenate the jobs so at the end of first automatically start the second and so on? In this way i don't have loss of time between one job and the next (now i've scheduled one job every hour but i've a lot of time lost).
Thanks,
Gio.
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello Gio,
Yes, you can easily do that. What you need to do, is go ahead and create (edit) a job, and on the last page of the configuration, where you click "finish", there is a window that populates the command line for that job.
Example:
Command line: C:\Program Files\Veeam\Backup and FastSCP\VeeamManager.exe" backup 421daae1-188e-4a1d-b7a4-d23a13af9fc9
You can use this for your scripting tasks (sequence) with the help of batch files (insert the line above to the batch file) and point to that batch file at the post backup job script box at advanced settings of your job's configurations, so your jobs could start one by one triggering each other by this way.
This is what relates to our current release, however in our upcoming release of Veeam Backup and Replicaton version 4, there is a integration with PowerShell, that will surely give you more options to play with.
Thank you.
Yes, you can easily do that. What you need to do, is go ahead and create (edit) a job, and on the last page of the configuration, where you click "finish", there is a window that populates the command line for that job.
Example:
Command line: C:\Program Files\Veeam\Backup and FastSCP\VeeamManager.exe" backup 421daae1-188e-4a1d-b7a4-d23a13af9fc9
You can use this for your scripting tasks (sequence) with the help of batch files (insert the line above to the batch file) and point to that batch file at the post backup job script box at advanced settings of your job's configurations, so your jobs could start one by one triggering each other by this way.
This is what relates to our current release, however in our upcoming release of Veeam Backup and Replicaton version 4, there is a integration with PowerShell, that will surely give you more options to play with.
Thank you.
-
- Chief Product Officer
- Posts: 31709
- Liked: 7215 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: Help! How can execute 7 job in sequence?
Alternatively, you can daisy chain all jobs using post-job script functionality under advanced job settings. Schedule the 1st job in chain to start on schedule, and disable scheduled starts for all other jobs. Every next jobs in the chain will be autostarted as a post-job activity from previous job. You should still use the same command line to start jobs as Vitaly mentioned in the previous post.
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2009 4:11 pm
- Full Name: Gioachino
- Contact:
Re: Help! How can execute 7 job in sequence?
Thanks for Reply!!!
I've already tried with batch file to run post-job script functionality but it doesn't run...
The job that i want to start with batch is called "Server03"; this is the batch:
Cd\Program Files\Veeam\Veeam Backup and FastSCP\
VeeamManager.exe backup Server03
The batch run without errors but the job don't start... what i'm mistaking?
Gio.
I've already tried with batch file to run post-job script functionality but it doesn't run...
The job that i want to start with batch is called "Server03"; this is the batch:
Cd\Program Files\Veeam\Veeam Backup and FastSCP\
VeeamManager.exe backup Server03
The batch run without errors but the job don't start... what i'm mistaking?
Gio.
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2009 4:11 pm
- Full Name: Gioachino
- Contact:
Re: Help! How can execute 7 job in sequence?
Also using the command line:
"C:\Program Files\Veeam\Veeam Backup and FastSCP\VeeamManager.exe" backup Server03
doesn't run and and give no errors...
"C:\Program Files\Veeam\Veeam Backup and FastSCP\VeeamManager.exe" backup Server03
doesn't run and and give no errors...
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello Gio,
You need to actually copy the command from wizard step where you click "finish"? Instead of "Server03" there should be the job's ID, so it looks like this:
"C:\Program Files\Veeam\Backup and FastSCP\VeeamManager.exe" backup b3672123-3206-4a88-805f-7c3a50403ef5
This will make your job start using script, after you check that the script starts the job, please use this batch file as post backup job script.
Thank you.
You need to actually copy the command from wizard step where you click "finish"? Instead of "Server03" there should be the job's ID, so it looks like this:
"C:\Program Files\Veeam\Backup and FastSCP\VeeamManager.exe" backup b3672123-3206-4a88-805f-7c3a50403ef5
This will make your job start using script, after you check that the script starts the job, please use this batch file as post backup job script.
Thank you.
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2009 4:11 pm
- Full Name: Gioachino
- Contact:
Re: Help! How can execute 7 job in sequence?
Sorry!
I wasn't able to find the Job's ID as You explain me and so i discover that probably 've used the wrong forum... I've Veeam Backup and Fast SCP.
I'll re-post the question in the "Veeam FastSCP forum"
Excuse me for the mistake...
Thanks to all,
Gio.
I wasn't able to find the Job's ID as You explain me and so i discover that probably 've used the wrong forum... I've Veeam Backup and Fast SCP.
I'll re-post the question in the "Veeam FastSCP forum"
Excuse me for the mistake...
Thanks to all,
Gio.
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello Gio,
You're correct in choosing that forum, please have a look at the screenshot (i've sent you with private message) explaining where to get the command. If you still have any issues, please email us to support@veeam.com
Thank you
You're correct in choosing that forum, please have a look at the screenshot (i've sent you with private message) explaining where to get the command. If you still have any issues, please email us to support@veeam.com
Thank you
-
- Influencer
- Posts: 13
- Liked: never
- Joined: Nov 30, 2009 9:00 pm
- Full Name: Luix
- Contact:
Re: Help! How can execute 7 job in sequence?
Hi,
i wanna serialize some jobs with a batch dos script and i want check the exit status of a job before starting the following.
What is the variable that i've to check? Perhaps %ERRORLEVEL%?
Thanks
i wanna serialize some jobs with a batch dos script and i want check the exit status of a job before starting the following.
What is the variable that i've to check? Perhaps %ERRORLEVEL%?
Thanks
-
- Chief Product Officer
- Posts: 31709
- Liked: 7215 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello, here's the thread answering your question:
http://www.veeam.com/forums/viewtopic.p ... job+result
Thanks!
http://www.veeam.com/forums/viewtopic.p ... job+result
Thanks!
-
- Veeam ProPartner
- Posts: 553
- Liked: 103 times
- Joined: Dec 29, 2009 12:48 pm
- Full Name: Marco Novelli
- Location: Asti - Italy
- Contact:
Re: Help! How can execute 7 job in sequence?
Nice thread, please consider as a feature request to add to Veeam GUI an option to easily concatenate and order backup jobs to run them serialized
Marco
Marco
-
- Enthusiast
- Posts: 78
- Liked: 2 times
- Joined: Jun 21, 2010 5:30 am
- Full Name: Dmitry Prokudin
Re: Help! How can execute 7 job in sequence?
Hi, Vitaliy!Vitaliy S. wrote: Command line: C:\Program Files\Veeam\Backup and FastSCP\VeeamManager.exe" backup 421daae1-188e-4a1d-b7a4-d23a13af9fc9
Is "421daae1-188e-4a1d-b7a4-d23a13af9fc9" constant attribute of backup job?
It will be the same on any editing this backup job?
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
Yes, it is the same. No changes will be made to this ID after editing. Please note that you can also use PowerShell scripts to execute jobs in sequence.
-
- Influencer
- Posts: 10
- Liked: never
- Joined: Feb 14, 2011 8:09 am
- Full Name: David Keis
- Contact:
Re: Help! How can execute 7 job in sequence?
Hi. First post here... hope it's ok that I 'hijack' this thread
I am having the same problem as Gio described; Many backup jobs that I want to execute sequentially.
I could add each new job as a post-job command to the previous job, and just be happy with that. However, I need to also be able to execute the jobs I have individually, without triggering all the other jobs at the same time.
I realise that the problem could be solved by adding duplicates of all the jobs at hand, so i'd have 2 backup jobs for each VM (one for scheduled backup and one for manual backup). That seems like a not-very-elegant solution.
I have tried creating a .bat script to trigger the jobs one after another, but I have not yet found a way to make the .bat script wait for the current job to finish, before starting the next job.
Is there a way to achieve the above?
I am having the same problem as Gio described; Many backup jobs that I want to execute sequentially.
I could add each new job as a post-job command to the previous job, and just be happy with that. However, I need to also be able to execute the jobs I have individually, without triggering all the other jobs at the same time.
I realise that the problem could be solved by adding duplicates of all the jobs at hand, so i'd have 2 backup jobs for each VM (one for scheduled backup and one for manual backup). That seems like a not-very-elegant solution.
I have tried creating a .bat script to trigger the jobs one after another, but I have not yet found a way to make the .bat script wait for the current job to finish, before starting the next job.
Is there a way to achieve the above?
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello David,
Yes, there is another way.
You need to use PowerShell script that checks current status of the backup job, and then based on the output triggers other jobs.
Should more details be required, please take a look at these links:
Post Script in Backup
Veeam Backup v4 wait command (nevermind the title)
Hope it helps!
Yes, there is another way.
You need to use PowerShell script that checks current status of the backup job, and then based on the output triggers other jobs.
Should more details be required, please take a look at these links:
Post Script in Backup
Veeam Backup v4 wait command (nevermind the title)
Hope it helps!
-
- Influencer
- Posts: 10
- Liked: never
- Joined: Feb 14, 2011 8:09 am
- Full Name: David Keis
- Contact:
Re: Help! How can execute 7 job in sequence?
Hi Vitaliy.
Thanks for the quick reply. And I'm glad to hear that it is possible.
I have tried several commands to execute the backup job, but I have not yet been successful. (I think mostly due to the fact that I did not know of PowerShell until a few days ago!)
Could you please point me in the right direction with the syntax for the Start-VBRJob command?
I have tried several combinations of the following code snippets:
The name of the job in Veeam GUI is: backup dkvam-cimio1
The ID of the job is: 80d989b8-1ed8-4812-a1d6-d54fa7bcee50 -given in the final window of the settings for the job.
Thanks for the quick reply. And I'm glad to hear that it is possible.
I have tried several commands to execute the backup job, but I have not yet been successful. (I think mostly due to the fact that I did not know of PowerShell until a few days ago!)
Could you please point me in the right direction with the syntax for the Start-VBRJob command?
I have tried several combinations of the following code snippets:
Code: Select all
Start-VBRJob "backup dkvam-cimio1"
Start-VBRJob 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
Start-VBRJob "C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" backup 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
The ID of the job is: 80d989b8-1ed8-4812-a1d6-d54fa7bcee50 -given in the final window of the settings for the job.
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute 7 job in sequence?
David, please check out this topic in order to make it work: Problem with Start-VBRJob
-
- Influencer
- Posts: 10
- Liked: never
- Joined: Feb 14, 2011 8:09 am
- Full Name: David Keis
- Contact:
Re: Help! How can execute 7 job in sequence?
Thank you very much.
Seems to be working now
Seems to be working now
-
- Enthusiast
- Posts: 58
- Liked: never
- Joined: Jan 01, 2006 1:01 am
Can a 2nd job be started once the first job is finished?
[merged]
Hi,
Just want to know:
Is it possible to let Queue2 start when Queue1 is finished? For example by using a script configured in the 'post job activity' setting?
Regards,
Joris
Hi,
Just want to know:
Is it possible to let Queue2 start when Queue1 is finished? For example by using a script configured in the 'post job activity' setting?
Regards,
Joris
-
- Enthusiast
- Posts: 29
- Liked: 2 times
- Joined: Oct 13, 2011 11:46 am
- Contact:
chained backup
[merged]
Probably not the best subject hint... Is there a way to start a second backup after the first is done automagically ? I have server servers kicking off at different times but would like to have them fire off after the previous is finished in a.... chain reaction
Probably not the best subject hint... Is there a way to start a second backup after the first is done automagically ? I have server servers kicking off at different times but would like to have them fire off after the previous is finished in a.... chain reaction
-
- Enthusiast
- Posts: 40
- Liked: 5 times
- Joined: Jan 25, 2011 2:12 pm
- Full Name: Olivier Druard
- Contact:
Re: Help! How can execute 7 job in sequence?
Hello,davidkeis wrote:I have tried creating a .bat script to trigger the jobs one after another, but I have not yet found a way to make the .bat script wait for the current job to finish, before starting the next job.
I encountered such a problem as our jobs are started with an external scheduler which needed to know when job were finish to start following tasks.
I solved problem using 2 batchs.
The first one is used to start job. You just need to give the job ID as parameter.
The script log start time, delete the previously created flag, start the job, wait for the flag file indicating the end of job, then log end time.
Code: Select all
@echo off
:Start
for /F "tokens=1,2,3 delims=/, " %%i in ('date /T') do set vdate=%%k%%j%%i
for /F "tokens=1,2 delims=:, " %%i in ('time /T') do set vtime=%%i%%j
echo %vdate%-%vtime% - Start >>D:\VeeamBackupWorkDir\Scripts\Logs\%1.txt
if exist D:\VeeamBackupWorkDir\Scripts\Flags\%1.flag del D:\VeeamBackupWorkDir\Scripts\Flags\%1.flag
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" backup %1
:Wait
timeout 60 >nul
if exist D:\VeeamBackupWorkDir\Scripts\Flags\%1.flag goto end
goto Wait
:End
for /F "tokens=1,2,3 delims=/, " %%i in ('date /T') do set vdate=%%k%%j%%i
for /F "tokens=1,2 delims=:, " %%i in ('time /T') do set vtime=%%i%%j
echo %vdate%-%vtime% - End >>D:\VeeamBackupWorkDir\Scripts\Logs\%1.txt
Code: Select all
@echo off
echo %vdate%-%vtime% >>D:\VeeamBackupWorkDir\Scripts\Flags\%1.flag
Olivier Druard
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute jobs in sequence?
Hi Olivier,
Thanks for sharing, but I just wanted to mention that you can always review the current job status with Powershell and use this status for triggering subsequent jobs.
On a side note, v6 will most likely remove any need in scheduling jobs like that, as job processing will be handled automatically.
Thanks.
Thanks for sharing, but I just wanted to mention that you can always review the current job status with Powershell and use this status for triggering subsequent jobs.
On a side note, v6 will most likely remove any need in scheduling jobs like that, as job processing will be handled automatically.
Thanks.
-
- Enthusiast
- Posts: 29
- Liked: 2 times
- Joined: Oct 13, 2011 11:46 am
- Contact:
Re: Help! How can execute jobs in sequence?
At the end of the post script do I have just pust the job id or prefix the id with "backup" or name of the job + the id? for example :
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
or
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" "backup" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
or
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" "ServerTest" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
or
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" "backup" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
or
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" "ServerTest" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute jobs in sequence?
The first variant:
Code: Select all
"C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Manager.exe" 80d989b8-1ed8-4812-a1d6-d54fa7bcee50
-
- Chief Product Officer
- Posts: 31709
- Liked: 7215 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: Help! How can execute jobs in sequence?
Just copy and use the command as seen on the Summary page of the job wizard. No need to be guessing, it's already there for you to use
-
- Enthusiast
- Posts: 29
- Liked: 2 times
- Joined: Oct 13, 2011 11:46 am
- Contact:
Re: Help! How can execute jobs in sequence?
Ahhhhhhhhhhh.... So I see
Thanks Gostev
Thanks Gostev
-
- Enthusiast
- Posts: 29
- Liked: 2 times
- Joined: Oct 13, 2011 11:46 am
- Contact:
Re: Help! How can execute jobs in sequence?
Ok this worked great but... Without thinking about the daisy chain the backup is only as good as its weakest link. About my 6th VM a backup post script failed thus not continuing. Is there a way I can setup a "upon failure continue" type of command in the post script? Where if a backup fails for one server the rest of the chain doesnt fail
-
- VP, Product Management
- Posts: 27325
- Liked: 2778 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Help! How can execute jobs in sequence?
This would be possible to do with PowerShell only, take a look at existing discussion for more details: post-job enhancement request
-
- Chief Product Officer
- Posts: 31709
- Liked: 7215 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: Help! How can execute jobs in sequence?
Not possible because this is how post-job script is designed to work (on success only). However, as Vitaly pointed, you may want to use PowerShell script with multiple Start-VBRJob calls instead, and launch it from Windows Scheduler.
-
- Novice
- Posts: 6
- Liked: never
- Joined: Dec 26, 2010 1:14 pm
- Full Name: Damien BASTIÉ
- Contact:
Re: Help! How can execute jobs in sequence?
Hi,
I am not a powerfull powershell user, but i can share my work...
I adapted RichardR's (http://forums.veeam.com/viewtopic.php?f=2&t=5107) script to my own usage (maybe i can optimize certain parts)
There is 3 hardcoded variables, $MaxJobs, $MaxRetry and $Folder
My script select jobs where the targetdir is equal to $Folder
Run $MaxJobs jobs concurrently
When all jobs are finished, i control if there are failed job and retry it concurrently using $MaxJobs and $MaxRetry
(sorry comments are in french)
I adapted pizzim13's script (http://forums.veeam.com/viewtopic.php?f=2&t=8925) for my reporting to a single veeam instance and all job :
I am not a powerfull powershell user, but i can share my work...
I adapted RichardR's (http://forums.veeam.com/viewtopic.php?f=2&t=5107) script to my own usage (maybe i can optimize certain parts)
There is 3 hardcoded variables, $MaxJobs, $MaxRetry and $Folder
My script select jobs where the targetdir is equal to $Folder
Run $MaxJobs jobs concurrently
When all jobs are finished, i control if there are failed job and retry it concurrently using $MaxJobs and $MaxRetry
(sorry comments are in french)
Code: Select all
# Ajout du snapin Veeam
Add-PSSnapin VeeamPSSnapIn
# Initialisation des variables
$JobList=@()
$MaxJobs=2
$MaxRetry=3
$Folder="D:\Veeam3\*"
$retry=1
# Fonction de vérification de $MaxJobs
Function TestMaxJobs {
Do {
$RunningJobs=@()
# Comptage du nombre de jobs en cours pour $Folder
ForEach ($JobR in $JobList) {
Get-VBRBackupSession | Where { $_.Name -eq $JobR -and $_.State -eq "Working" } | ForEach {$RunningJobs += $_.Name}
}
# Si supérieur ou égal à $MaxJobs
If ($RunningJobs.count -ge $MaxJobs) {
# Attente de 60 secondes
Start-Sleep -s 30
}
}
# Le Do-While continue tant qu'il y a $MaxJobs en cours
While ($RunningJobs.count -ge $MaxJobs)
}
# Fonction d'attente de fin de job
Function WaitEndJob {
# En attente des jobs non terminés
Do {
$RunningJobs=@()
# Comptage du nombre de jobs en cours pour $Folder
ForEach ($JobR in $JobList) {
Get-VBRBackupSession | Where { $_.Name -eq $JobR -and $_.State -eq "Working" } | ForEach {$RunningJobs += $_.Name}
}
# Si supérieur ou égal à 1
If ($RunningJobs.count -ge 1) {
# Attente de 60 secondes
Start-Sleep -s 60
}
}
# Le Do-While continue tant qu'il y a au moins 1 job en cours
While ($RunningJobs.count -ge 1)
}
# Récupération de la liste des jobs pour $Folder
Get-VBRJob | Where {$_.Info.TargetDir -like $Folder} | ForEach {$JobList += $_.Name}
# Tri des jobs par ordre alphabétique
$JobList = $JobList | Sort-Object
# Pour chaque Jobs
ForEach ($Job in $JobList) {
# Vérification de $MaxJobs
TestMaxJobs
# Sinon le job démarre
Get-VBRJob | where {$_.Name -eq $Job} | ForEach {Start-VBRJob $_ -RunAsync}
# Attente de 30 secondes avant de recommence en haut du ForEach
Start-Sleep -s 30
}
# En attente des jobs non terminés
WaitEndJob
# Tant que le $retry est inférieur à $MaxRetry
While ($retry -le $MaxRetry) {
# Combien de job en failed ?
$FailedJobs=@()
Get-VBRJob | Where {$_.Info.TargetDir -like $Folder -and $_.Info.LatestStatus -eq "Failed"} | ForEach {$FailedJobs += $_.Name}
# Si pas de failed le Exit
if ($FailedJobs.count -eq 0) {
break
}
# +1 pour $retry
$retry++
# Initialisation de JobList
$JobList =@()
# Récupération de la liste des jobs en Failed à retry pour $Folder
Get-VBRJob | Where {$_.Info.TargetDir -like $Folder -and $_.Info.LatestStatus -eq "Failed"} | ForEach {$JobList += $_.Name}
# Tri des jobs par ordre alphabétique
$JobList = $JobList | Sort-Object
ForEach ($Job in $JobList) {
# Vérification de $MaxJobs
TestMaxJobs
# Sinon le job démarre
Get-VBRJob | where {$_.Name -eq $Job} | ForEach {Start-VBRJob $_ -RetryBackup -RunAsync}
# Attente de 30 secondes avant de recommence en haut du ForEach
Start-Sleep -s 30
}
# En attente des jobs non terminés
WaitEndJob
}
Code: Select all
Add-PSSnapin VeeamPSSnapIn
$JobStatus=@()
#html styling
$style = "<style>"
$style = $style + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$style = $style + "TH{border-width: 1px;padding: 1px;border-style:double;border-color: black;}"
$style = $style + "TD{border-width: 1px;padding: 5px;border-style:double;border-color: black;}"
$style = $style + "</style>"
$JobStatus = (Get-VBRJob | Where-Object {$_.findlastsession().progress.stoptime -ge (Get-Date).addhours(-12)}) |
ForEach-Object {
$_ | Select-Object @{Name="Job";Expression={$_.Name}}, @{Name="Status";Expression={$_.GetLastResult()}},
@{Name="Job Msg";Expression={$_.FindLastSession().info.description}}, @{Name="Start Time";Expression={$_.FindLastSession().Progress.StartTime}},
@{Name="End Time";Expression={$_.FindLastSession().Progress.StopTime}},@{Name="Duration";Expression={'{0:N0}' -f $_.FindLastSession().Progress.Duration.TotalMinutes}}
}
###Sending report
#Mail settings
$MailSrv = "MailSrv"
$MailFrom = "MailFrom"
$MailTo = "MailTo"
$MailSbjt = "Veeam Job Status Report $(get-date)"
$MailBody = ($JobStatus | Select-Object Job, Status, "Job Msg", "Start Time", "End Time", Duration | Sort-Object Job | ConvertTo-Html -Head $style | Out-String) `
-replace ("<td>Success","<td bgcolor=green> Success") `
-replace ("<td>Warning","<td bgcolor=yellow> Warning") `
-replace ("<td>Failed","<td bgcolor=red>Failed")
Send-MailMessage -SmtpServer $MailSrv -From $MailFrom -To $MailTo -Subject $MailSbjt -Body $MailBody -BodyAsHtml
###
Who is online
Users browsing this forum: AdsBot [Google], Baidu [Spider], Gostev, Robobeat and 116 guests