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