Skip to content
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

Backup support for mercury #387

Open
wants to merge 2 commits into
base: mercury_dev
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public static string GetServiceClientProviderType(CmdletModel.WorkloadType workl
case CmdletModel.WorkloadType.AzureFiles:
providerType = ServiceClientModel.BackupManagementType.AzureStorage.ToString();
break;
case CmdletModel.WorkloadType.MSSQL:
providerType = ServiceClientModel.BackupManagementType.AzureWorkload.ToString();
break;
default:
break;
}
Expand Down Expand Up @@ -353,4 +356,4 @@ public static string GetServiceClientWorkloadType(CmdletModel.WorkloadType workl
return serviceClientWorkloadType;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.RecoveryServices.Backup.Models;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Azure sql database workload Item Class
/// </summary>
public class AzureWorkloadSQLDatabaseProtectedItem : AzureItem
{
/// <summary>
/// friendly name of the DB represented by this backup item.
/// </summary>
public string FriendlyName { get; set; }

/// <summary>
/// host/Cluster Name for instance or AG.
/// </summary>
public string ServerName { get; set; }

/// <summary>
/// parent name of the DB such as Instance or Availability Group.
/// </summary>
public string ParentName { get; set; }

/// <summary>
/// protected item, example: for a DB, standalone server
/// or distributed.
/// </summary>
public string ParentType { get; set; }

/// <summary>
/// error details in last backup
/// </summary>
public ErrorDetail LastBackupErrorDetail { get; set; }

/// <summary>
///ID of the protected item.
/// </summary>
public string ProtectedItemDataSourceId { get; set; }

/// <summary>
/// health status of the backup item
/// </summary>
public string ProtectedItemHealthStatus { get; set; }

/// <summary>
/// Constructor. Takes the service client object representing the protected item
/// and converts it in to the PS protected item model
/// </summary>
/// <param name="protectedItemResource">Service client object representing the protected item resource</param>
/// <param name="containerName">Name of the container associated with this protected item</param>
/// <param name="containerType">Type of the container associated with this protected item</param>
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
public AzureWorkloadSQLDatabaseProtectedItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType, policyName)
{
AzureVmWorkloadSQLDatabaseProtectedItem protectedItem = (AzureVmWorkloadSQLDatabaseProtectedItem)protectedItemResource.Properties;
FriendlyName = protectedItem.FriendlyName;
ServerName = protectedItem.ServerName;
ParentName = protectedItem.ParentName;
ParentType = protectedItem.ParentType;
LastBackupErrorDetail = protectedItem.LastBackupErrorDetail;
ProtectedItemDataSourceId = protectedItem.ProtectedItemDataSourceId;
ProtectedItemHealthStatus = protectedItem.ProtectedItemHealthStatus;
LastBackupStatus = protectedItem.LastBackupStatus;
LastBackupTime = protectedItem.LastBackupTime;
ProtectionState =
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
}
}

/// <summary>
/// Azure Workload Item ExtendedInfo Class
/// </summary>
public class AzureWorkloadSQLDatabaseProtectedItemExtendedInfo : AzureItemExtendedInfo
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public enum ItemParams
BackupManagementType,
ExpiryDateTimeUTC,
StorageAccountName,
BackupType,
EnableCompression
}

public enum ProtectionCheckParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public enum ContainerType
/// <summary>
/// Represents any Azure Storage containers.
/// </summary>
AzureStorage
AzureStorage,

/// <summary>
/// Represents any Azure Workload containers.
/// </summary>
AzureWorkload
}

/// <summary>
Expand Down Expand Up @@ -70,6 +75,7 @@ public enum BackupManagementType
/// Represents Azure File Storage. https://docs.microsoft.com/en-in/azure/storage/files/storage-files-introduction
/// </summary>
AzureStorage,
AzureWorkload,
}

/// <summary>
Expand Down Expand Up @@ -103,6 +109,7 @@ public enum WorkloadType
/// Represents Azure File https://docs.microsoft.com/en-in/azure/storage/files/storage-files-introduction
/// </summary>
AzureFiles,
MSSQL,
}

/// <summary>
Expand Down Expand Up @@ -134,6 +141,7 @@ public enum PsBackupProviderTypes
/// Represents the Azure File provider for powershell cmdlets.
/// </summary>
AzureFiles,
AzureWorkload,
}

/// <summary>
Expand Down Expand Up @@ -334,4 +342,15 @@ public enum SourceFileType
File,
Directory
}
}

/// <summary>
/// Type of the backup.
/// </summary>
public enum BackupType
{
Full,
Differential,
Log,
CopyOnlyFull
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ public static BackupManagementType GetPsBackupManagementType(string backupManage
return BackupManagementType.AzureSQL;
case ServiceClientModel.BackupManagementType.AzureStorage:
return BackupManagementType.AzureStorage;
case ServiceClientModel.BackupManagementType.AzureWorkload:
return BackupManagementType.AzureWorkload;
default:
throw new Exception("Unsupported BackupManagmentType: " + backupManagementType);
}
Expand Down Expand Up @@ -248,6 +250,11 @@ public static ContainerType GetPsContainerType(string containerType)
{
return ContainerType.AzureStorage;
}
else if (containerType ==
ServiceClientModel.BackupManagementType.AzureWorkload)
{
return ContainerType.AzureWorkload;
}
else
{
throw new Exception("Unsupported ContainerType: " + containerType);
Expand All @@ -265,14 +272,18 @@ public static WorkloadType GetPsWorkloadType(string workloadType)
{
return WorkloadType.AzureVM;
}
if (workloadType == ServiceClientModel.WorkloadType.AzureSqlDb.ToString())
else if (workloadType == ServiceClientModel.WorkloadType.AzureSqlDb.ToString())
{
return WorkloadType.AzureSQLDatabase;
}
if (workloadType == ServiceClientModel.WorkloadType.AzureFileShare)
else if (workloadType == ServiceClientModel.WorkloadType.AzureFileShare)
{
return WorkloadType.AzureFiles;
}
else if (workloadType == ServiceClientModel.WorkloadType.SQLDataBase)
{
return WorkloadType.MSSQL;
}
else
{
throw new Exception("Unsupported WorkloadType: " + workloadType);
Expand All @@ -290,14 +301,18 @@ public static string GetServiceClientWorkloadType(string workloadType)
{
return ServiceClientModel.WorkloadType.VM;
}
if (workloadType == WorkloadType.AzureSQLDatabase.ToString())
else if (workloadType == WorkloadType.AzureSQLDatabase.ToString())
{
return ServiceClientModel.WorkloadType.AzureSqlDb;
}
if (workloadType == WorkloadType.AzureFiles.ToString())
else if (workloadType == WorkloadType.AzureFiles.ToString())
{
return ServiceClientModel.WorkloadType.AzureFileShare;
}
else if (workloadType == WorkloadType.MSSQL.ToString())
{
return ServiceClientModel.WorkloadType.SQLDataBase;
}
else
{
throw new Exception("Unsupported WorkloadType: " + workloadType);
Expand All @@ -315,10 +330,14 @@ public static string GetARMResourceType(string workloadType)
{
return "Microsoft.Compute/virtualMachines";
}
if (workloadType == WorkloadType.AzureFiles.ToString())
else if (workloadType == WorkloadType.AzureFiles.ToString())
{
return "Microsoft.Storage/storageAccounts";
}
else if (workloadType == WorkloadType.MSSQL.ToString())
{
return "VMAppContainer";
}

throw new Exception("Unsupported WorkloadType: " + workloadType);
}
Expand All @@ -335,12 +354,16 @@ public static string GetWorkloadTypeFromArmType(string armType)
{
return WorkloadType.AzureVM.ToString();
}
if (string.Compare(armType, "Microsoft.Storage/storageAccounts", ignoreCase: true) == 0)
else if (string.Compare(armType, "Microsoft.Storage/storageAccounts", ignoreCase: true) == 0)
{
return WorkloadType.AzureFiles.ToString();
}
else if (string.Compare(armType, "VMAppContainer", ignoreCase: true) == 0)
{
return WorkloadType.MSSQL.ToString();
}

throw new Exception("Unsupported ArmType: " + armType);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\tools\Common.Dependencies.targets" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{02234E90-BCDE-4B20-B1F5-01B1005821DB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.Commands.RecoveryServices.Backup.Providers</RootNamespace>
<AssemblyName>Microsoft.Azure.Commands.RecoveryServices.Backup.Providers</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DefineConstants>TRACE;SIGN</DefineConstants>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.3.0.1-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AzureWorkloadProviderHelper.cs" />
<Compile Include="IPsBackupProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\AzureFilesPsBackupProvider.cs" />
<Compile Include="Providers\AzureSqlPsBackupProvider.cs" />
<Compile Include="Providers\AzureWorkloadPsBackupProvider.cs" />
<Compile Include="Providers\DpmPsBackupProvider.cs" />
<Compile Include="Providers\MabPsBackupProvider.cs" />
<Compile Include="PsBackupProviderManager.cs" />
<Compile Include="Providers\IaasVmPsBackupProvider.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Profile\Commands.Profile\Commands.Profile.csproj">
<Project>{142d7b0b-388a-4ceb-a228-7f6d423c5c2e}</Project>
<Name>Commands.Profile</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Helpers\Commands.RecoveryServices.Backup.Helpers.csproj">
<Project>{0e1d3f36-e6c8-4764-8c7d-6f9ee537490c}</Project>
<Name>Commands.RecoveryServices.Backup.Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Logger\Commands.RecoveryServices.Backup.Logger.csproj">
<Project>{5e675749-6139-464a-904c-59c0ffdfec82}</Project>
<Name>Commands.RecoveryServices.Backup.Logger</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Models\Commands.RecoveryServices.Backup.Models.csproj">
<Project>{30b92759-50b3-494e-b9f0-ec9a2ce9d57b}</Project>
<Name>Commands.RecoveryServices.Backup.Models</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.ServiceClientAdapter\Commands.RecoveryServices.Backup.ServiceClientAdapter.csproj">
<Project>{b758fec1-35c1-4f93-a954-66dd33f6e0ec}</Project>
<Name>Commands.RecoveryServices.Backup.ServiceClientAdapter</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
using Microsoft.Azure.Management.Internal.Resources.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using Microsoft.Rest.Azure.OData;
using System;
Expand Down
Loading