PS: Veeam Replication Start/Stop Scripts

1 minute read

Description:

I used the following scripts to start/stop replications for Veeam so that we can run backups on the VM’s in question. After saving them to C:\Scripts, I just set them as a scheduled task to run before and after backups are ran.

To Resolve:

  1. Veeam Stop Script:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    #Enable the Veeam Powershell Snapin
    Add-PsSnapin VeeamPsSnapin
    
    #Specify Jobs
    $jobs = "VM1", "VM2", "VM3"
    $date = get-date -format G
    
    #Disable each job and verify its schedule options. Write the result to veeam-log.txt
    
    foreach ($job in $jobs)
       {
       $CurrentJob = Get-VBRJob -name $job
       $CurrentJob | Disable-VBRJob
          if ($CurrentJob.IsScheduleEnabled -eq $True)
          {
          write-output "$date = FAILED to disable $job. Please take appropriate action." >> C:\Scripts\veeam-log.txt
          }
          else
          {
          write-output "$date = Successfully disabled $job" >> C:\Scripts\veeam-log.txt 
          }
       }
    
  2. Veeam Start Script:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    #Enable the Veeam Powershell Snapin
    Add-PsSnapin VeeamPsSnapin
    
    #Specify Job names
    $jobs = "VM1", "VM2", "VM3"
    
    #Get the date for result output
    $date = get-date -format G
    
    #Enable each job and verify its schedule options. Write the result to veeam-log.txt
    
       foreach ($job in $jobs)
       {
       $CurrentJob = Get-VBRJob -name $job | Enable-VBRJob
          If ($CurrentJob.IsScheduleEnabled -eq $True)
          {
          write-output "$date = Successfully started $job" >> C:\Scripts\veeam-log.txt
          }
          else
          {
          write-output "$date = FAILED to enable $job. Please take appropriate action." >> C:\Scripts\veeam-log.txt
          }
       }
    
  3. Set these as a scheduled task to run with your backups.

  4. Source is maintained under gwApplications and gwApplications

-----------------------------------------------------------
Spotted a mistake in this article? Why not suggest an edit!
Did you like the article? Donations are always welcome!
-----------------------------------------------------------

Comments