PowerShell script exchange
Post Reply
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

import VeeamZips from linux repo

Post by nd39475 »

I have manually moved my VeeamZip *.vbk files to a new linux veeamrepo. I expected to easily import with powershell, but as it turns out, the import script that i used is specific to an invoke-command for windows. Is there a way to get a linux directory listing (ls *.vbk) from within powershell.

here is my script for a windows import:

Code: Select all

. "C:\Program Files\Veeam\Backup and Replication\Console\Initialize-VeeamToolkit.ps1"

$VeeamServerName = "VeeamRepo-Zip"
$VeeamServerObj = (Get-VBRBackupRepository -Name $VeeamServerName)
$RepoPath = (Get-VBRBackupRepository -Name $VeeamServerName).FriendlyPath

Write-Host "Server:",($VeeamServerObj).Name
Write-Host "Path:",$RepoPath

$files = Invoke-Command -ComputerName $VeeamServerName -ScriptBlock {ls "$Using:RepoPath/VeeamZIP/*.vbk"}

foreach ($file in $files) {
    Write-Host "Importing $VeeamServerName $File.FullName"
    Import-VBRBackup -Server $VeeamServerObj -FileName $file.FullName
}
where the `$file = invoke-command ` is windows specific.



I would happily do it via GUI, however, there is no wildcard or full folder import. I would have to select each .vbk individually which is unacceptable.
Image
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: import VeeamZips from linux repo

Post by david.domask » 1 person likes this post

Hi @nd39475,

I suppose it's mostly about how do you get Powershell to talk to Linux. There isn't a supported way in Veeam right now to connect and list the contents of an added server (there are unsupported ways but there's some complexity here), so I suppose you need to use an additional module, POSH-SSH: https://github.com/darkoperator/Posh-SSH

Please note that POSH-SSH is not supported in any fashion by Veeam. Please install powershell modules with discretion and consideration.

Install this module, then you will do something like:

Code: Select all

$Credentials = Get-Credential -Username "your username" -Message "Enter Password"
$SSHSess = New-SSHSession -ComputerName computernameorIP -Credential $Credentials -AcceptKey #remove -AcceptKey if you want to validate the ssh key yourself
$SSHOutPut = (Invoke-SSHCommand -SSHSession $SSHSess -Command "find /path/to/your/repository/folder -type f -name '*.vbk'").Output
Remove-SSHSession -Name $SSHSess | Out-Null
With this, $SSHOutPut will have your VBK files, and you can then do:

Code: Select all

$Repository = Get-VBRBackupRepository -name 'name of the repository you want to import into'
foreach($b in $SSHOutPut){
Import-VBRBackup -Filename $b -Repository $Repository
}
David Domask | Product Management: Principal Analyst
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: import VeeamZips from linux repo

Post by david.domask » 1 person likes this post

Addendum: I should note that Powershell/Microsoft _do_ have some more official ways of doing PSRemoting over SSH, but in my opinion, it's overly complex for what you're trying to do, and I think the above should be more convenient in the long run.
David Domask | Product Management: Principal Analyst
nd39475
Enthusiast
Posts: 58
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: import VeeamZips from linux repo

Post by nd39475 »

thank you very kindly David !
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests