Skip to content

Commit 97d1738

Browse files
committed
Merge pull request Azure#1849 from hchungmsft/dev
Cmdlets for Azure RM Backup/Restore
2 parents 6ca1bef + be77b40 commit 97d1738

21 files changed

+25381
-14157
lines changed

ChangeLog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##2016.03.08 version 1.3.0
1+
##2016.03.08 version 1.3.0
22
* Azure LogicApp: New cmdlets for managing LogicApps
33
* Get-AzureLogicAppAccessKey
44
* Get-AzureLogicApp
@@ -22,6 +22,11 @@
2222
- New-AzureStorageShareSASToken
2323
- New-AzureStorageQueueSASToken
2424
- New-AzureStorageTableSASToken
25+
* Azure SQL DB Backup/restore
26+
* Get-AzureRmSqlDatabaseGeoBackup
27+
* Get-AzureRmSqlDeletedDatabaseBackup
28+
* Restore-AzureRmSqlDatabase
29+
* This cmdlet accepts as pipelined input the result of one of the first two cmdlets (or Get-AzureRmSqlDatabase if restoring a live DB to a point-in-time)
2530

2631
## 2016.02.04 version 1.2.1
2732
* Fix installer issue - remove PSGallery modules on install

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
</Reference>
7272
<Reference Include="Microsoft.Azure.Management.Sql">
7373
<SpecificVersion>False</SpecificVersion>
74-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.44.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.45.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
7575
</Reference>
7676
<Reference Include="Microsoft.Azure.Management.Storage">
7777
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
@@ -223,7 +223,7 @@
223223
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
224224
</None>
225225
<None Include="ScenarioTests\DatabaseBackupTests.ps1">
226-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
226+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
227227
</None>
228228
<None Include="ScenarioTests\RecommendedElasticPoolTests.ps1">
229229
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -414,6 +414,15 @@
414414
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestListDatabaseRestorePoints.json">
415415
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
416416
</None>
417+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestoreDeletedDatabaseBackup.json">
418+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
419+
</None>
420+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestoreGeoBackup.json">
421+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
422+
</None>
423+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestorePointInTimeBackup.json">
424+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
425+
</None>
417426
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreate.json">
418427
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
419428
</None>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,23 @@ public void TestListDatabaseRestorePoints()
2626
{
2727
RunPowerShellTest("Test-ListDatabaseRestorePoints");
2828
}
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestRestoreGeoBackup()
32+
{
33+
RunPowerShellTest("Test-RestoreGeoBackup");
34+
}
35+
[Fact]
36+
[Trait(Category.AcceptanceType, Category.CheckIn)]
37+
public void TestRestoreDeletedDatabaseBackup()
38+
{
39+
RunPowerShellTest("Test-RestoreDeletedDatabaseBackup");
40+
}
41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void TestRestorePointInTimeBackup()
44+
{
45+
RunPowerShellTest("Test-RestorePointInTimeBackup");
46+
}
2947
}
3048
}

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,43 @@ function Test-ListDatabaseRestorePoints
5252
{
5353
Remove-ResourceGroupForTest $rg
5454
}
55+
}
56+
57+
function Test-RestoreGeoBackup
58+
{
59+
# Setup
60+
$location = "Southeast Asia"
61+
$serverVersion = "12.0"
62+
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test2
63+
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr2 -ResourceGroupName $rg.ResourceGroupName
64+
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb-geo2 -ResourceGroupName $rg.ResourceGroupName
65+
$restoredDbName = "powershell_db_georestored"
66+
67+
Get-AzureRmSqlDatabaseGeoBackup -ResourceGroupName $server.ResourceGroupName -ServerName $server.ServerName -DatabaseName $db.DatabaseName | Restore-AzureRmSqlDatabase -FromGeoBackup -TargetDatabaseName $restoredDbName
68+
}
69+
70+
function Test-RestoreDeletedDatabaseBackup
71+
{
72+
# Setup
73+
$location = "Southeast Asia"
74+
$serverVersion = "12.0"
75+
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test2
76+
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr2 -ResourceGroupName $rg.ResourceGroupName
77+
$droppedDbName = "powershell_db_georestored"
78+
$restoredDbName = "powershell_db_deleted"
79+
80+
Get-AzureRmSqlDeletedDatabaseBackup -ResourceGroupName $server.ResourceGroupName -ServerName $server.ServerName -DatabaseName $droppedDbName -DeletionDate "2016-02-23T00:21:22.847Z" | Restore-AzureRmSqlDatabase -FromDeletedDatabaseBackup -TargetDatabaseName $restoredDbName
81+
}
82+
83+
function Test-RestorePointInTimeBackup
84+
{
85+
# Setup
86+
$location = "Southeast Asia"
87+
$serverVersion = "12.0"
88+
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test
89+
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr -ResourceGroupName $rg.ResourceGroupName
90+
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb -ResourceGroupName $rg.ResourceGroupName
91+
$restoredDbName = "powershell_db_restored"
92+
93+
Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $db.DatabaseName | Restore-AzureRmSqlDatabase -FromPointInTimeBackup -PointInTime "2016-02-20T00:06:00Z" -TargetDatabaseName $restoredDbName
5594
}

0 commit comments

Comments
 (0)