forked from rubrikinc/rubrik-scripts-for-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-FileSetSnapshot.ps1
More file actions
executable file
·103 lines (80 loc) · 3.37 KB
/
New-FileSetSnapshot.ps1
File metadata and controls
executable file
·103 lines (80 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<#
.SYNOPSIS
Will create a new snapshot of a fileset on a server
.DESCRIPTION
.PARAMETER Server
IP address or DNS name to Rubrik Cluster
.PARAMETER FileSetName
Name of the Fileset created in Rubrik
.PARAMETER HostName
Name of the server that will be backed up
.PARAMETER SLADomain
Name of the SLA Domain
.PARAMETER CredentialFile
Path and filename of encrypted credential file
.INPUTS
None
.OUTPUTS
SUCCESS is a boolean value. $True if snapshot is successfull and $false if not.
.EXAMPLE
.\New-FileSetSnapshot.ps1 -Server 172.21.8.51 -FileSetName 'Ola Hallengren SQL Backup Files' -HostName cl-sql2012n1.rangers.lab' -SLADomain 'SQL User Databases' -CredentialFile .\CredentialFile.Cred
.LINK
None
.NOTES
Name: New FIle Set Snapshot
Created: 5/2/2018
Author: Chris Lumnah
Execution Process:
1. Before running this script, you need to create a credential file so that you can securly log into the Rubrik
Cluster. To do so run the below command via Powershell
$Credential = Get-Credential
$Credential | Export-CliXml -Path .\rubrik.Cred"
The above will ask for a user name and password and them store them in an encrypted xml file.
2. Execute this script via the example above.
#>
param
(
[Parameter(Mandatory=$true,HelpMessage="IP address or DNS name to Rubrik Cluster")]
[string]$Server,
[Parameter(Mandatory=$true,HelpMessage="Name of the Fileset created in Rubrik")]
[string]$FileSetName,
[Parameter(Mandatory=$true,HelpMessage="Name of the server that will be backed up")]
[string]$HostName,
[Parameter(Mandatory=$true,HelpMessage="Name of the SLA Domain")]
[string]$SLADomain,
[Parameter(Mandatory=$true,HelpMessage="Path and filename of encrypted credential file")]
[string]$CredentialFile
)
Import-Module Rubrik
$Credential = Import-CliXml -Path $CredentialFile
Connect-Rubrik -Server $Server -Credential $Credential | Out-Null
$RubrikFileSet = Get-RubrikFileset -Name $FileSetName -HostName $HostName
$RubrikRequest = New-RubrikSnapshot -id $RubrikFileSet.id -SLA $SLADomain -Confirm:$false
#Evaluate the request. Based on the status of the Async request, we will show the progress. We will exit if failure or success
#If failure, we return false, but success we return true
do
{
$exit = $false
$success=$false
$Request = Get-RubrikRequest -id $RubrikRequest.id -Type 'fileset'
switch -Wildcard ($Request.status)
{
'QUE*' {Write-Progress -Activity "Backup up fileset $FileSetName on $HostName" -Status $Request.status -percentComplete (0)}
'RUN*'
{
if ([string]::IsNullOrEmpty($Request.progress)){$PercentComplete = 0} else {$PercentComplete = $Request.progress}
Write-Progress -Activity "Backup up fileset $FileSetName on $HostName" -Status $Request.status -percentComplete $PercentComplete
}
'SUCCEED*'
{
$exit = $true
$success = $true
}
'FAIL*'
{
$exit = $true
$success = $false
}
}
}until ($exit -eq $true)
$success