Skip to main content
I have been looking at some information within the Veeam documentation, but it could not move forward due to some errors according to images.

 

Is this specifically related to Veeam Recovery Orchestrator @Fvinas ?  If not then we can get this moved to the Discussion board for broader help and guidance.

@Madi.Cristil @safiya -- If this is not related to VRO specifically can we move it to Discussion board as a question?

 
 
 

Yes, Perfect.


Yes, Perfect.

Yes it is related to VRO or better to be moved?  Please clarify.


YES, You can move to a discussion group. About the topic. VB&R Reference PowerShell for SQLExplorer Restore.

YES, You can move to a discussion group. About the topic. VB&R Reference PowerShell for SQLExplorer Restore.

Ok so it looks like it was moved you are in a good spot now.


I have been looking at some information within the Veeam documentation, but it could not move forward due to some errors according to images.

 

This error usually means that you are running PowerShell from a system that does not have Veeam installed or requires that you install the Console at least to register with PowerShell to run commands.


Hi @Fvinas which version of Veeam are you using? The snap in was replaced with a PowerShell module in v11


Hey, I'm currently on version 12.1

Here’s the documentation you need then: https://helpcenter.veeam.com/docs/backup/explorers_powershell/from_windows_powershell.html?ver=120

🙂


Por supuesto, ya he estado viendo la documentacion al repecto.  Add-PSSnapin -Name VeeamPSSnapIn no esta registrado y si trato de registrarlo no hace nada.

 


Please re-read my comment above where I explained the snap in was replaced with a module in v11, as you have the module you simply need to run “Connect-VBRServer” cmdlet


Por supuesto, ya he estado viendo la documentacion al repecto.  Add-PSSnapin -Name VeeamPSSnapIn no esta registrado y si trato de registrarlo no hace nada.

 

Hola @Fvinas,

 

Como ya te han comentado varios compañeros el comando “VeeamPSSnapIn” desde la versión v11 de Veeam no es utilizado. Ahora en la versiones recientes se utiliza el comando Import-Module para inicializar los cmdlet de Veeam aunque en mi experiencia los módulos son cargados automáticamente.

 

PS C:\Users\jocolon> Get-Module -Name Veeam.* -ListAvailable | Select-Object -Property Name,Version

Name Version
---- -------
Veeam.Diagrammer 0.6.1
Veeam.Documentor 1.0
Veeam.Archiver.PowerShell 6.0
Veeam.ExchangeOnlineManagement 1.0.1
Veeam.ExchangeOnlineManagement 1.0.1
Veeam.ExchangeOnlineManagement 1.0.1
Veeam.Exchange.PowerShell 2.0
Veeam.SharePoint.PowerShell 2.0
Veeam.Teams.PowerShell 2.0
Veeam.Backup.PowerShell 12.1.2.172
Veeam.ActiveDirectory.PowerShell 1.0
Veeam.Oracle.PowerShell 1.0
Veeam.PostgreSQL.PowerShell 1.0
Veeam.SapHana.PowerShell 1.0
Veeam.SQL.PowerShell 1.0


PS C:\Users\jocolon>

 

Como sea para cargar los módulos de Veeam y Veeam.SQL puedes utilizar los siguientes comandos:

 

Para inicializar todos los módulos de Veeam:

PS C:\Users\jocolon> Import-Module -Name Veeam.Archiver.PowerShell -Force
PS C:\Users\jocolon> Import-Module -Name Veeam.Backup.PowerShell -Force
PS C:\Users\jocolon> Import-Module -Name Veeam.SQL.PowerShell -Force

Si se presenta algún error puedes cargar el módulo de Veeam.SQL.PowerShell de forma manual:

PS C:\Users\jocolon> Import-Module "C:\Program Files\Veeam\Backup and Replication\Explorers\SQL\Veeam.SQL.PowerShell\Veeam.SQL.PowerShell.psd1"

 

Para validar que los cmdlet han sido inicializados puedes hacer una búsqueda con el cmdlet Get-Command:

 

PS C:\Users\jocolon> Get-Command -Module Veeam.SQL.PowerShell | Select-Object -Property Name,Source

Name Source
---- ------
Disable-VESQLExtendedLogging Veeam.SQL.PowerShell
Enable-VESQLExtendedLogging Veeam.SQL.PowerShell
Export-VESQLDatabase Veeam.SQL.PowerShell
Export-VESQLPublishedDatabase Veeam.SQL.PowerShell
Get-VESQLCommand Veeam.SQL.PowerShell
Get-VESQLDatabase Veeam.SQL.PowerShell
Get-VESQLDatabaseFile Veeam.SQL.PowerShell
Get-VESQLDatabaseRestoreInterval Veeam.SQL.PowerShell
Get-VESQLExtendedLogging Veeam.SQL.PowerShell
Get-VESQLIRDatabase Veeam.SQL.PowerShell
Get-VESQLPublishedDatabase Veeam.SQL.PowerShell
Get-VESQLRestoreSession Veeam.SQL.PowerShell
New-VESQLIRSwitchOverOptions Veeam.SQL.PowerShell
Publish-VESQLDatabase Veeam.SQL.PowerShell
Restore-VESQLDatabase Veeam.SQL.PowerShell
Restore-VESQLIRDatabase Veeam.SQL.PowerShell
Set-VESQLIRDatabase Veeam.SQL.PowerShell
Start-VESQLRestoreSession Veeam.SQL.PowerShell
Stop-VESQLInstantRecovery Veeam.SQL.PowerShell
Stop-VESQLRestoreSession Veeam.SQL.PowerShell
Switch-VESQLIRDatabase Veeam.SQL.PowerShell
Unpublish-VESQLDatabase Veeam.SQL.PowerShell


PS C:\Users\jocolon>

Espero esto pueda ser de ayuda!


@jcolonfzenpr 

Ya había comentado que no tengo mucho expertos sobre el tema, y es por eso que estoy en la comunidad, para ver cómo puede ayudar la asistencia por parte de todos, ahora bien, ya había dicho que necesito restaurar las base de datos de algunas tenares de SQL que tengo en mi plataforma para de esta manera el DBA al mismo tiempo también haga la automatización por su parte.

He visto algunos ejemplos de como ir viendo los diferentes comandos, pero no he llegado a concluir nada.

 

 


 Hola @Fvinas,

 

Sería un poco difícil desarrollar una solución de automatización desde este portal. Te recomiendo que utilices el Foro de Veeam donde estoy seguro que encontrarás las respuestas que buscas.

https://forums.veeam.com/powershell-f26/

 

Por otro lado, cuentas con la licencia para “Veeam Enterprise Manager”?

 

Desde allí puedes crear una cuenta con privilegios de “Restore Operator” solo para que los usuario restauren las bases de datos.

 

Ejemplo de creación de usuario en “Enterprise Manager”:

 

Desde el “Self Service Restore Portal” el usuario puede restaurar las bases de datos por sí mismo.

Saludos,


SI claro y atengo esta parte habilidada. Pero el DBA lo que requiere es que se hagan por la via de POwerShell para tenerlo y solo ejecutar el script.


@Fvinas, sorry for English, but as I get it you need a script to restore SQL DBs via Powershell, correct?

I wrote this for a case a bit back but you can use it as a reference. You _CAN_ customize this a lot and use additional features based on the cmdlets, but this basic workflow should help:

 

Example script from forums: https://forums.veeam.com/powershell-f26/sql-db-restore-script-t76226.html

 

There is an example of a workflow built by a forum user, however this is the same as what we have in https://helpcenter.veeam.com/docs/backup/explorers_powershell/restore-vesqldatabase.html?ver=120, and I will briefly walk through the process.

$sqlRP = Get-VBRApplicationRestorePoint -SQL -Name "name of the restore point as shown in the UI"
$session = Start-VESQLRestoreSession -RestorePoint $sqlRP
$dbToRestore = Get-VESQLDatabase -Session $session -Name "name of the database to restore"
$files = Get-VeSqlDatabaseFile -Database $dbToRestore
$paths = @{"C:\Full\Path\To\New\File\Location.mdf","C:\Full\Path\To\New\File\Location_log.ldf") #only needed if you want custom paths for MDF/LDF files. Your DBA can tell you if this is needed
Restore-VESQLDatabase -Database $dbToRestore -File $files -TargetPath $paths -GuestCredentials sPSCredentialObject] -SqlCredentials sPSCredentialObject]

 

This is the basic workflow.

 

1. Start by fetching the necessary VBRApplicationRestorePoint object and save it to a variable. This will return an array of all restore points, so you will likely need to sort the list by passing the results of Get-VBRApplicationRestorePoint | Sort-Object -Property CreationTime -Descending. This will ensure the most recent restore point is the first one.

2. Start a VESQLRestoreSession using the desired restore point. To use the first restore point in an array, you would use u0], e.g., Start-VESQLRestoreSession -RestorePoint $sqlRPq0]

3. Locate the database you intend to restore with Get-VESQLDatabase.

4. Save the files returned by Get-VESQLDatabaseFile to a variable -- likely you will want to parse out the actual filenames from the returned data to build your paths in the next step.

5. (optional if you don’t want to change the location of MDF/LDF) The $paths variable accepts an array of the full paths that you want to restore to. In my example above, the restore would place the files on C:\Full\Path\To\New\File\ with the respective names for the MDF and LDF files.

6. Start the restore with Restore-VESQLDatabase. The .PSCredentialObject] must be built using the native Powershell tooling to build a credential -- this is a rather manual process, but many credential managers have integration with Powershell that allows Powershell to get oPSCredentialObject] into the shell. To do this manually, we would use something like:

$pass = ConvertTo-SecureString "Abc123$%" -AsPlainText -Force #the password does not _have_ to be in plain text in a script, it can for example be taken from a secured file on the Veeam Server to avoid passwords in plaintext.

$PSCredential = New-Object System.Management.Automation.PSCredential("dd-sql-test\Administrator",$pass)

 

The process listed above is an example of how to perform the restore to custom location; logic for correctly setting the servers, filenames, new database names, and further will need to be discussed and worked on within your team as this will need to be customized to your needs and environment.


Hello, @mascara I have not taken any action yet, but if it is possible to see the idea of ​​what I want to do since I am only the one who manages the backups, not the APPLICATION DATABASE,  to see if you can help me with this, not with the restoration. It is necessary for me to enter the credentials from the SQL admin, I only need to remove the databases from the Veeam backup repository and place them on another server, and from that location the dba will do its restorations. If this Script is modified, how would it be without that part of the credentials, put the other server into operation and everything that involves the start-up. I just needed to take out the last backup of that database and place it on another server.

 

 


Comment