Inicio > virtualización > Veeam Backup & PowerShell: ejecución de backups en remoto

Veeam Backup & PowerShell: ejecución de backups en remoto

Fuente:  http://forums.veeam.com/viewtopic.php?f=26&t=13471

Fuente: http://forums.veeam.com/viewtopic.php?f=26&t=13372

Andys scripting corner – Beginners guide

Postby Andreas Neufert » Wed Sep 12, 2012 1:50 pm 2 people like this post

Hello everybody,here you are right if you have no idea of powershell or Veeam scriptig. This is a really basic guide.So lets start to run the existing backup job “test” with powershell.

1. Install Backup & Replication on a Windows machine
– tick the powershell enhancment at the setup to enable powershell support. (If you installed it without, reinstall it without uninstallation => New setup find all settings)
– Add Hosts, Cluster, VCenter or VMM of your choice.
– Add a backupjob “test” and run the backup (if there are errors solve them with support).

2. Start powershell editor
– Together with actual Windows Servers and Clients there came a free powershell editor named “Windows PowerShell ISE”. At some Winodws Version you have to add it in the server manager under “features”.

3.Create a new script
– Write the following code to a new script

Code: Select all
write-host "Test"

- Save it as “Test.ps1″ and run it in the “Windows PowerShell ISE” (Play button).
At the bottom you can see the output. If you see an error
“… cannot be loaded because the execution of scripts is disabled on this system.”
you need to set Powershell Execution Policy to allow custom unsigned scripts. See Microsoft Website: Set-ExecutionPolicy (External Link)

If you run into the error: “VeeamPSSnapIn” isn´t installed please check Register VeeamPSSnapIn

4.Load Veeam Powershell module
– After the above script runs without problems it is time to implement the first Veeam commands.
– We load the Veeam Powershell snapin with the command “Add-PSSnapin”.
– If you run your script more then once in the editor it says that VeeamPSSnapIn already loaded. You can prefent this if you add ” -ErrorAction SilentlyContinue”

So the code is now

Code: Select all
write-host "Starting Veeam Job test"
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

5.Write job name to a varaible
$JobName = “test”

Code: Select all
write-host "Starting Veeam Job test"
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$JobName = "test"

6. Load job object
If we will now try to start the job with this variable, we will run in an error, because we handover “only” the name of the job, but the command expect the handover of all job informationes (the whole job object).
So we read out the compleate job object with:
Get-VBRJob | where {$_.Name -eq $JobName}

and write it to a new variable
$JobObject = Get-VBRJob | where {$_.Name -eq $JobName}

Code: Select all
write-host "Starting Veeam Job test"
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$JobName = "test"
$JobObject = Get-VBRJob | where {$_.Name -eq $JobName}

7. Start job
Now we add the start job command with:

Code: Select all
write-host "Starting Veeam Job test"
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$JobName = "test"
$JobObject = Get-VBRJob | where {$_.Name -eq $JobName}
Start-VBRJob $JobObject

Thats it… have fun with our powershell.

If you want to enhance this script. Have a look at
Andys scripting corner – Ultimate start job script
CU Andy

Andreas Neufert
Veeam Software
 
Posts: 345
Liked: 43 times
Joined: Wed May 04, 2011 8:36 am
Full Name: Andreas Neufert @AndyandtheVMs Veeam SE
About these ads
  1. Aún no hay comentarios.
  1. No trackbacks yet.

Deja un comentario

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

Seguir

Recibe cada nueva publicación en tu buzón de correo electrónico.

A %d blogueros les gusta esto: