Advertisement
allywilson

Move Netbackup Database

Aug 28th, 2017
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Powershell adaptation ofprocess defined here: https://www.veritas.com/support/en_US/article.TECH135546
  2. Write-host "Make sure you have run bpdown before running this script!" -ForegroundColor Yellow
  3. $title = "Create alternate path"
  4. $message = "Are you sure you want to continue?"
  5. $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Create the alternate path."
  6. $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Do not create the alternate path."
  7. $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
  8. $Result = $host.ui.PromptForChoice($title,$message,$options, 0)
  9. switch ($Result)
  10.     {
  11.         0 {New-AltPath}
  12.         1 {break}
  13.     }
  14.  
  15. function New-AltPath {
  16.     $originalPath = "D:\Program Files\Veritas\NetBackup\db\images"
  17.     $newPath = "E:\alternate_db\images"
  18.     $clientDirs = Get-childitem -Directory -path $originalPath
  19.  
  20.     Foreach ($clientDir in $clientDirs){
  21.         $altPathFile = $clientDir.FullName+"\ALTPATH"
  22.         $altPathFileCheck = Test-Path $altPathFile
  23.         If ($altPathFileCheck -eq $false){
  24.             $newPathClientDir = $newPath+"\"+$clientDir.Name
  25.             Try{
  26.                 Copy-Item $clientDir.FullName -Recurse -filter * -Destination $newPathClientDir -ErrorAction Stop
  27.                 $newPathClientDir | Out-File $altPathFile -Encoding ascii # If this isn't ascii/ansi then Netbackup can't read it.
  28.                 Write-host "Copy successful, created ALTPATH, now make sure backups and restores working for client before deleting everything except ALTPATH file in" $clientDir.FullName
  29.             }
  30.             Catch{
  31.                 Write-host "Something went wrong during the copy, error details..."
  32.                 $error[0] | fl * -property *
  33.             }
  34.         }
  35.         else {Write-host "ALTPATH file exists, doing nothing."}
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement