Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu hızlı başlangıç, bir Azure Bicep dosyasıyla PostgreSQL için Azure Veritabanı - Esnek Sunucu yedeklemesini yapılandırmanın nasıl yapılacağını açıklar.
Azure Backup , Azure portal, PowerShell, CLI, Azure Resource Manager, Bicep gibi birden çok istemci kullanarak Azure PostgreSQL - Esnek sunucularınızı yedeklemenize olanak tanır. Bu makale, Bir Yedekleme kasası oluşturmak ve ardından Azure PostgreSQL - Esnek Sunucu için yedeklemeyi yapılandırmak üzere bir Bicep dosyası dağıtma işlemine odaklanır. Bicep dosyaları geliştirme hakkında daha fazla bilgi edinin.
Bicep, Azure kaynaklarını bildirimli olarak dağıtmaya yönelik bir dildir. Azure Resource Manager şablonlarınızı (ARM şablonları) geliştirmek için JSON yerine Bicep kullanabilirsiniz. Bicep söz dizimi karmaşıklığı azaltır ve geliştirme deneyimini geliştirir. Bicep, tüm JSON şablon özelliklerini sağlayan ARM şablonu JSON üzerinde saydam bir soyutlamadır. Dağıtım sırasında Bicep CLI, bicep dosyasını ARM şablonu JSON'a dönüştürür. Bicep dosyası, kaynak oluşturmak için bir dizi programlama komutu yazmadan Azure kaynaklarını ve kaynak özelliklerini belirtir.
ARM şablonunda geçerli olan kaynak türleri, API sürümleri ve özellikler de bicep dosyasında geçerlidir.
Önkoşullar
Bicep geliştirme ortamınızı ayarlamak için Bicep araçlarını yükleme konusuna bakın.
Dikkat
Makalede ayrıntılı olarak açıklandığı gibi en son Azure PowerShell modülünü ve Bicep CLI'yi yükleyin.
Şablonu gözden geçirme
Bu şablon, Azure PostgreSQL - Esnek sunucu için yedekleme yapılandırmanızı sağlar. Bu şablonda postgreSQL sunucusu için haftalık zamanlamaya ve üç aylık saklama süresine sahip bir yedekleme ilkesine sahip bir yedekleme kasası oluşturacağız.
@description('Specifies the name of the Backup Vault')
param backupVaultName string
@description('Specifies the name of the Resource group to which Backup Vault belongs')
param backupVaultResourceGroup string
@description('Specifies the name of the PostgreSQL server')
param postgreSQLServerName string
@description('Specifies the name of the Resource group to which PostgreSQL server belongs')
param postgreSQLResourceGroup string
@description('Specifies the region in which the Backup Vault is located')
param region string
@description('Specifies the name of the Backup Policy')
param policyName string
@description('Specifies the frequency of the backup schedule')
param backupScheduleFrequency string
@description('Specifies the retention duration in months')
param retentionDuration string
@description('Step 1: Create the Backup Vault')
resource backupVault 'Microsoft.DataProtection/backupVaults@2023-01-01' = {
name: backupVaultName
location: region
identity: {
type: 'SystemAssigned'
}
properties: {
storageSettings: [
{
datastoreType: 'VaultStore'
type: 'LocallyRedundant'
}
]
}
}
@description('Step 2: Create Backup Policy for PostgreSQL')
resource backupPolicy 'Microsoft.DataProtection/backupVaults/backupPolicies@2023-01-01' = {
name: '${backupVaultName}/${policyName}'
location: region
properties: {
datasourceTypes: [
'AzureDatabaseForPostgreSQLFlexibleServer'
]
policyRules: [
{
name: 'BackupSchedule'
objectType: 'AzureBackupRule'
backupParameters: {
objectType: 'AzureBackupParams'
}
trigger: {
schedule: {
recurrenceRule: {
frequency: 'Weekly'
interval: backupScheduleFrequency
}
}
}
dataStore: {
datastoreType: 'VaultStore'
}
}
{
name: 'RetentionRule'
objectType: 'AzureRetentionRule'
isDefault: true
lifecycle: {
deleteAfter: {
objectType: 'AbsoluteDeleteOption'
duration: 'P${retentionDuration}M'
}
}
}
]
}
}
@description('Step 3: Role Assignment for PostgreSQL Backup And Export Operator Role')
resource postgreSQLServer 'Microsoft.DBforPostgreSQL/flexibleServers@2022-03-01' existing = {
name: postgreSQLServerName
scope: resourceGroup(postgreSQLResourceGroup)
}
resource roleAssignmentBackupExportOperator 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(backupVault.id, 'PostgreSQLFlexibleServerLongTermRetentionBackupRole')
properties: {
principalId: backupVault.identity.principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e') // Role definition ID for 'PostgreSQL Backup And Export Operator'
scope: postgreSQLServer.id
}
}
@description('Step 4: Role Assignment for Reader on Resource Group')
resource targetResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
name: targetResourceGroupName
}
resource roleAssignmentReader 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(backupVault.id, 'Reader')
properties: {
principalId: backupVault.identity.principalId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '00aa00aa-bb11-cc22-dd33-44ee44ee44ee') // Role definition ID for 'Reader'
scope: targetResourceGroup.id
}
}
@description('Step 5: Create Backup Instance for PostgreSQL)
resource backupInstance 'Microsoft.DataProtection/backupVaults/backupInstances@2023-01-01' = {
name: 'PostgreSQLBackupInstance'
location: region
properties: {
datasourceInfo: {
datasourceType: 'AzureDatabaseForPostgreSQLFlexibleServer'
objectType: 'Datasource'
resourceId: postgreSQLServer.id
}
policyInfo: {
policyId: backupPolicy.id
}
}
}
Şablonu dağıtma
Bu şablonu dağıtmak için GitHub'da veya tercih ettiğiniz konumda depolayın ve ardından kabuk penceresine aşağıdaki PowerShell betiğini yapıştırın. Kodu yapıştırmak için kabuk penceresine sağ tıklayın ve yapıştır'ı seçin.
$projectName = Read-Host -Prompt "Enter a project name (limited to eight characters) that is used to generate Azure resource names"
$location = Read-Host -Prompt "Enter the location (for example, centralus)"
$resourceGroupName = "${projectName}rg"
$templateUri = "templateURI"
New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -projectName $projectName
Sonraki adımlar
Azure PowerShellkullanarak PostgreSQL için Azure Veritabanı - Esnek sunucuyu geri yükleyin.