Skip to content

Cmdlets for Azure RM Backup/Restore #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Feb 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##2016.03.08 version 1.3.0
##2016.03.08 version 1.3.0
* Azure LogicApp: New cmdlets for managing LogicApps
* Get-AzureLogicAppAccessKey
* Get-AzureLogicApp
Expand All @@ -22,6 +22,11 @@
- New-AzureStorageShareSASToken
- New-AzureStorageQueueSASToken
- New-AzureStorageTableSASToken
* Azure SQL DB Backup/restore
* Get-AzureRmSqlDatabaseGeoBackup
* Get-AzureRmSqlDeletedDatabaseBackup
* Restore-AzureRmSqlDatabase
* 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)

## 2016.02.04 version 1.2.1
* Fix installer issue - remove PSGallery modules on install
Expand Down
13 changes: 11 additions & 2 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.44.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.45.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
Expand Down Expand Up @@ -223,7 +223,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DatabaseBackupTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\RecommendedElasticPoolTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -414,6 +414,15 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestListDatabaseRestorePoints.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestoreDeletedDatabaseBackup.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestoreGeoBackup.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRestorePointInTimeBackup.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,23 @@ public void TestListDatabaseRestorePoints()
{
RunPowerShellTest("Test-ListDatabaseRestorePoints");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRestoreGeoBackup()
{
RunPowerShellTest("Test-RestoreGeoBackup");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRestoreDeletedDatabaseBackup()
{
RunPowerShellTest("Test-RestoreDeletedDatabaseBackup");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRestorePointInTimeBackup()
{
RunPowerShellTest("Test-RestorePointInTimeBackup");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,43 @@ function Test-ListDatabaseRestorePoints
{
Remove-ResourceGroupForTest $rg
}
}

function Test-RestoreGeoBackup
{
# Setup
$location = "Southeast Asia"
$serverVersion = "12.0"
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test2
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr2 -ResourceGroupName $rg.ResourceGroupName
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb-geo2 -ResourceGroupName $rg.ResourceGroupName
$restoredDbName = "powershell_db_georestored"

Get-AzureRmSqlDatabaseGeoBackup -ResourceGroupName $server.ResourceGroupName -ServerName $server.ServerName -DatabaseName $db.DatabaseName | Restore-AzureRmSqlDatabase -FromGeoBackup -TargetDatabaseName $restoredDbName
}

function Test-RestoreDeletedDatabaseBackup
{
# Setup
$location = "Southeast Asia"
$serverVersion = "12.0"
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test2
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr2 -ResourceGroupName $rg.ResourceGroupName
$droppedDbName = "powershell_db_georestored"
$restoredDbName = "powershell_db_deleted"

Get-AzureRmSqlDeletedDatabaseBackup -ResourceGroupName $server.ResourceGroupName -ServerName $server.ServerName -DatabaseName $droppedDbName -DeletionDate "2016-02-23T00:21:22.847Z" | Restore-AzureRmSqlDatabase -FromDeletedDatabaseBackup -TargetDatabaseName $restoredDbName
}

function Test-RestorePointInTimeBackup
{
# Setup
$location = "Southeast Asia"
$serverVersion = "12.0"
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung-test
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr -ResourceGroupName $rg.ResourceGroupName
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb -ResourceGroupName $rg.ResourceGroupName
$restoredDbName = "powershell_db_restored"

Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $db.DatabaseName | Restore-AzureRmSqlDatabase -FromPointInTimeBackup -PointInTime "2016-02-20T00:06:00Z" -TargetDatabaseName $restoredDbName
}
Loading