PowerShell script exchange
McClane
Expert
Posts: 106
Liked: 11 times
Joined: Jun 20, 2009 12:47 pm
Contact:

Re: backup naming when using reversed incremental

Post by McClane » 1 person likes this post

If backup target is a local disk, I do this to get a consistent vkb filename after every backup job:

Code: Select all

if ((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null) {
   Add-PsSnapin VeeamPSSnapIn
}

$veeamJobName = "TaeglicheSicherung"
$jobFilename = "TaeglicheSicherung.vbk"

$BackupPath = "e:\VeeamBackups\TaeglicheSicherung"


if ((Get-VBRJob | ?{$_.Name -eq $veeamJobName}).GetLastResult() ) {
   $latestOib = Get-VBRBackup | ?{$_.JobName -eq $veeamJobName} | Get-VBRRestorePoint | Sort CreationTime -Descending | Select -First 1
   $latestOib
   $storage = $latestOib.GetStorage()
   $file = $storage.FileName

   & del $BackupPath\$jobFilename
   & cmd /c "mklink /H $BackupPath\$jobFilename $BackupPath\$file"
   
}
And for a backup target on a linux smb share I do that:

Code: Select all

if ((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null) {
   Add-PsSnapin VeeamPSSnapIn
}

$veeamJobName = "Taegliche_Sicherung"
$jobFilename = "Taegliche_Sicherung.vbk"

$toolPath = "c:\bktools"
$nasPath = "/share/backup"
$puttySession = "nas02"
$user = "admin"
$pw = "Passwort"


if ((Get-VBRJob | ?{$_.Name -eq $veeamJobName}).GetLastResult() -eq "Success") {
   $latestOib = Get-VBRBackup | ?{$_.JobName -eq $veeamJobName} | Get-VBRRestorePoint | Sort CreationTime -Descending | Select -First 1
   $latestOib
   $storage = $latestOib.GetStorage()
   $file = $storage.FileName

    & $toolPath\plink.exe "$puttySession" -pw "$pw" -l "$user" "rm $nasPath/$jobFilename;ln -s $nasPath/$file $nasPath/$jobFilename"
   
}
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests