Skip to content

Automation solution for the backup of Azure database for PostgreSQL Flexible Server

License

Notifications You must be signed in to change notification settings

sitMCella/azure-postgresql-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backup Automation for Azure PostgreSQL Flexible Server

Table of contents

Introduction

The following project configures one cronjob application in Azure Kubernetes Server to take full backups of a database on one Azure Database for PostgreSQL Flexible Server.

Requirements

  • Terraform
  • Azure CLI
  • Kubectl
  • Helm Chart
  • Helmfile

Terraform

Configuration

Assign the RBAC roles "Contributor", "User Access Administrator" to the User account on the Subscription level.

Create a file terraform.tfvars and specify the values for the following Terraform variables:

subscription_id="<subscription_id>"
location="<azure_region>" # e.g. "westeurope"
location_abbreviation="<azure_region_abbreviation>" # e.g. "weu"
environment="<environment_name>" # e.g. "test"
workload_name="<workload_name>"
postgresql_administrator_login="<postgresql_administrator_name>"
postgresql_administrator_password="<postgresql_administrator_password>"
allowed_public_ip_address_ranges=[<list_of_allowed_ip_address_ranges>] # Public IP Address ranges allowed to access the Azure resources e.g. "1.2.3.4/32"
allowed_public_ip_addresses=<[<list_of_allowed_ip_addresses>] # Public IP Addresses allowed to access the Azure resources  e.g. "1.2.3.4"

Before proceeding with the next sections, open a terminal and login in Azure with Azure CLI using the User account.

Terraform Project Initialization

terraform init -reconfigure

Verify the Updates in the Terraform Code

terraform plan

Apply the Updates from the Terraform Code

terraform apply -auto-approve

Format Terraform Code

find . -not -path "*/.terraform/*" -type f -name '*.tf' -print | uniq | xargs -n1 terraform fmt

Helm

Create Kubernetes Resources

cd helm
helmfile apply

Check Kubernetes Resources

kubectl get serviceaccount -n application
kubectl get secret -n application
kubectl get cronjob -n application

Delete Kubernetes Resources

cd helm
helmfile delete

Check CronJob

kubectl get jobs -n application
kubectl get pods --selector=job-name=<job-name> -n application
kubectl logs -f <pod-name> -n application

About

Automation solution for the backup of Azure database for PostgreSQL Flexible Server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published