UNSOLVED

DELL-Bill Gr

updated

15 years ago

0

13262

November 21st, 2011 11:00

Powershell Backup Script

This post has been copied from the former Compellent User Forum and placed here for your reference.  This code is made available AS IS, without warranty of any kind.  The entire risk of the use or the results from the use of this code remains with the user.

Backup Script – Originally posted by By HaysItDept, 09 Aug 2010

HaysItDept - I am struggling trying to get my replay views connected to my backup server.  They are connecting, but they show up in diskpart with the readonly, hidden,nodefaultdriveletter and shadowcopy attributes all marked yes.  Consequently the script is not assigning a drive letter or allowing me access to run the backup.

I have tried passing a diskpart script within the powershell but the disks are occasionally not available after the initial rescan-diskdevice is run and the volume numbers change each time the drives are rescanned?

I am running w2k3 on my exchange server and the backup server.

kalord - Can you post the code you are using?

pongowongo - In case you have not resolved this issue, or for anyone else that is having the same issue, you will want to perform these 3 steps before assigning your drive letter.

Set-DiskDevice -SerialNumber $Volume.SerialNumber -Online

Set-DiskDevice -SerialNumber $Volume.SerialNumber -ReadOnly:$false

Set-Volume -SerialNumber $Volume.SerialNumber -Readonly:$false -Hidden:$false -ClearShadowFlag

Regards,

Hugh

lboucher - I tried these things, but the drive letter was not being assigned to the drive.  You might try these commands, then look at the disk in diskpart and see what drive number it is coming in as and the volume number.  If the drive consistently comes in as the same disk number, you can use this command to map a drive letter to using powershell to pass these diskpart commands:

"select disk (number of your disk)", "select volume (number of the volume)", "assign letter=(drive letter you want)" | diskpart

I hope this helps.

Leo

sramsden - Not sure if this helps you but this is the script i use for making my backups using Backupexec 2010 R3.  Im pretty much a beginner in powershell but this script works everytime for the last months for several jobs.

I call this script in the pre processing job

Add-PSSnapin Compellent.StorageCenter.PSSnapin

$volumename = "LUN xxx"

$accesspath = "C:\Folder_xxx"

$user = "xxx"

$pass = ConvertTo-SecureString "*xxx" -AsPlainText -Force

$schost = "xxx"

$connection = Get-SCConnection -HostName $schost -User $user -Password $pass -Save $schost -Default

$replays = Get-SCReplay -SourceVolumeName $volumename | where{$_.State -eq "Frozen"}

$latestreplay = $replays[-1]

$newreplayname = "$volumename View " + $latestreplay.Index

$newreplayname | Out-File -FilePath "C:\Scripts\LOG\xxx.txt" -Append

$replayview = New-SCVolume -SourceReplay $latestreplay -Name $newreplayname

New-SCVolumeMap (Get-SCVolume -name $newreplayname) (Get-SCServer -Name "Backupserver name without the quotes") -SinglePath

Rescan-DiskDevice -Server "Backupserver name without the quotes" -RescanDelay 10

start-sleep -Seconds 20

Add-VolumeAccessPath -SerialNumber $replayview.SerialNumber -Server "Backupserver name without the quotes" -AccessPath $accesspath

Remove-PSSnapin Compellent.StorageCenter.PSSnapin

sramsden - then i call this script in the post processing job

Add-PSSnapin Compellent.StorageCenter.PSSnapin

$user = "xxx"

$pass = ConvertTo-SecureString "*xxx" -AsPlainText -Force

$schost = "xxx"

$connection = Get-SCConnection -HostName $schost -User $user -Password $pass -Save $schost -Default

$LastReplay = (Get-Content "C:\scripts\LOG\xxx.txt")[-1]

Remove-VolumeAccessPath -Server "Backup Server name" -AccessPath C:\Folder_xxx -Confirm:$false

Remove-SCVolume (Get-SCVolume -name $LastReplay) -SkipRecycleBin -Confirm:$false

Rescan-DiskDevice -Server "Backup Server name" -RescanDelay 5

Remove-PSSnapin Compellent.StorageCenter.PSSnapin