forked from geekzter/azure-minecraft-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_snapshots.ps1
executable file
·38 lines (32 loc) · 1.14 KB
/
manage_snapshots.ps1
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
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Create file share snapshots
#>
#Requires -Version 7
### Arguments
param (
[parameter(Mandatory=$false)][switch]$Create=$false
)
. (Join-Path $PSScriptRoot functions.ps1)
try {
AzLogin
$tfdirectory = $(Join-Path (Get-Item $PSScriptRoot).Parent.FullName "terraform")
Push-Location $tfdirectory
$storageAccount = (Get-TerraformOutput "storage_account")
$storageKey = (Get-TerraformOutput "storage_key")
$shareNames = (Get-TerraformOutput -OutputVariable "storage_data_share" -ComplexType)
if ($shareNames) {
foreach ($shareName in $shareNames) {
if ($Create) {
Write-Host "Creating snapshot of File Share $shareName in Storage Account ${storageAccount}..."
az storage share snapshot -n $shareName --account-name $storageAccount --account-key $storageKey
}
}
az storage share list --include-snapshots --account-name $storageAccount --account-key $storageKey -o table
} else {
Write-Warning "Storage File Share has not been created, nothing to do"
}
} finally {
Pop-Location
}