Declare a Backup Repository on Linux

PowerShell script exchange

Declare a Backup Repository on Linux

Veeam Logoby spp » Fri Dec 16, 2011 10:37 am

Hello.

I'm trying to add a Linux server with Powershell in v6, to make it host a Backup Repository Server.

Code: Select all
# add the Linux server
$secpasswd = ConvertTo-SecureString "pass" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("account", $secpasswd)
$srv=Add-VBRLinux -Name devspp -SSHUser root -SSHPassword "root_pass" -Credential $mycreds

# declare the new backup repository on the Linux server
$mntsrv=get-vbrserver | where {$_.Name -eq "This server"}
Add-VBRBackupRepository -Name "devspp_bkp_repo" -Server $srv -MountServer $mntsrv -Folder "/synerway/applishare/vmware_ultimate" -Type "LinuxLocal"



The "account" I'll use is a service account, not root, and I need to set the ElevateRoot and AutoSudo properties of the Linux server to "true".
To retrieve their values, I can use "$srv.GetSSHCreds()" on a VBRServer object.

Is there a way to set those properties with the SSH credentials?


Thanx a lot.
Sorin Pop.
spp
Novice
 
Posts: 8
Liked: never
Joined: Fri Dec 16, 2011 10:18 am
Full Name: Sorin Pop

Re: Declare a Backup Repository on Linux

Veeam Logoby ThomasMc » Fri Dec 16, 2011 8:34 pm

I can't test this but would this work?

Code: Select all
$srv = Add-VBRLinux -Name "devspp" -SSHUser "ServiceAccount" -SSHPassword "SAPASSWORD"
$vbrServer = Get-VBRServer -Name "devspp"
$creds = $vbrServer.getsshcreds()

$creds.ElevateToRoot = $true
$creds.EncryptedRootPassword = $mycreds
$vbrServer.SetCredentials($creds)


My assumptions are that you connect to ssh via this service account and elevating to root
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Declare a Backup Repository on Linux

Veeam Logoby spp » Tue Dec 20, 2011 9:27 am

Hello.

Thank you Thomas for your answer.
I will try to be more accurate.

I need to connect to a Linux server using ssh with this "service" account, so I have to elevate it to root and force the autosudo.

Actually, I'm trying to reproduce in Powershell this settings:

Image

Those PS cmdlets were supposed to give me that.

I also tried your idea:

Code: Select all
$srv=get-vbrserver | where {$_.Name -eq "spp4"}
$creds=$srv.getSSHCreds()
$creds.ElevateRoot=$true
$creds.AutoSudo=$true
$srv.setcredentials($creds)


and the result was a typecast error:

Code: Select all
Impossible de convertir l'argument « 0 » (valeur « Veeam.Backup.Model.CDBSshCreds ») de « SetCredentials » en type « Veeam.Backup.Common.CCredentials » : « Impossible de convertir la valeur « Veeam.Backup.Model.CDBSshCreds » du type « Ve
eam.Backup.Model.CDBSshCreds » en type « Veeam.Backup.Common.CCredentials ». »
Au niveau de C:\spp\scripts\add_linux_server.ps1 : 33 Caractère : 20
+ $srv.setcredentials <<<< ($creds)
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument


What can I do?

Thanx again.

Sorin
spp
Novice
 
Posts: 8
Liked: never
Joined: Fri Dec 16, 2011 10:18 am
Full Name: Sorin Pop

Re: Declare a Backup Repository on Linux

Veeam Logoby ThomasMc » Tue Dec 20, 2011 4:03 pm

Well I've had a good dig about and I have came to the conclusion that;

1) The Add-VBRLinux doesn't behave
2) Someone left out UpdateSshCreds

Code: Select all
Add-VBRLinux -Name "LinuxServer" -SSHUser "ServiceUser" -SSHPassword "SApassword"

$vbrServer = Get-VBRServer -Name "LinuxServer"
$creds = $vbrServer.getsshcreds()
$creds.ElevateRoot = $true
$creds.RootPassword = "RootPassword"

$Manager = [Veeam.Backup.DBManager.CDBManager]::Instance
$Manager.Host.UpdateSshCreds($creds)


Had to look back at a example from Seth to get this one :D
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Declare a Backup Repository on Linux

Veeam Logoby spp » Wed Dec 21, 2011 11:33 am

Hello,

Thank you, Thomas, nicely done, it works like a heart!
Pretty tricky though!

Thanks again.

Sorin
spp
Novice
 
Posts: 8
Liked: never
Joined: Fri Dec 16, 2011 10:18 am
Full Name: Sorin Pop


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests