SimpleBackupsSimpleBackups

How to backup PostgreSQL to Microsoft Azure

Last updated on

Originally posted on

Automate PostgreSQL database backup directly to your Microsoft Azure Blob Storage.

With SimpleBackups, you can backup a PostgreSQL database to any cloud storage provider. Below we go through the entire process of setting up your backup and storing it on Microsoft Azure Blob Storage specifically.

Prerequisites

  • Have a SimpleBackups account
  • Have a server connected to your account (the one on which your PostgreSQL database is hosted)
  • Have a Microsoft Azure Storage Account (it can be empty, we'll cover how to create your Azure blob storage below)

1. Create your Microsoft Azure Blob Storage

  • Sign in to your Microsoft Azure Portal.

  • Under Azure services, choose Storage Accounts. Your storage account list will be displayed. Choose the storage account you want to connect with.

Microsoft Azure Storage Account

  • On the left menu, under Blob Service, choose Containers

Microsoft Azure Storage Container

  • Click + Container to add a Container. Input the name you want for the container and click the Create button

  • Your container has been created.

    Information you'll need in step 3:

  • Container Name

  • Storage Endpoint, in this case is core.windows.net

2. Get your Storage Access Keys

In order to give access to your newly created storage, you'll need to provide credentials to SimpleBackups.

  • On the left menu, under Settings, choose Access Keys.

Microsoft Azure Storage Access Keys

  • Please use the Key value under key1 as your access key.

Information you'll need in step 3:

  • Access Key
  • Storage Account Name

3. Connect your Azure Blob Storage to SimpleBackups

  • Log into SimpleBackups and head to the connect your storage page
  • Select "Azure Blob Storage" in the storage providers list and fill in the "Connect your storage" form with your Microsoft Azure credentials and newly created container information

Azure storage backup - Connect storage

You'll have to input :

  • Account Name: Account Name described in (step 2)
  • Access Key: Secret Key described in (step 2)
  • Container: Container name described in (step 1)
  • Ending Suffix: your storage endpoint described in (step 1)
  • Give your storage a name (usually we like to use the storage name) and click on "Save new storage".

You'll be redirected to the list of storage where you'll find your newly connected storage.

SimpleBackups, Microsoft Azure Blob Storage Connected

4. Final step: Create your PostgreSQL backup

Now it's time to head to the create backup page.

SimpleBackups - Create PostgreSQL backup

What would you like to back up? (A)

  • Select "Database" (in this article we're creating a PostgreSQL backup only)
  • Select the server on which your database is hosted

How often should we make this backup? (B)

  • Select your schedule option (here we picked a daily schedule)

    You can select a pre-defined schedule (daily, weekly, monthly) or a custom option allowing you to schedule it whenever you want to use CRON syntax.

  • Example of CRON schedule for "20:00 every Tuesday" = 0 22 * * 2

    Finally, the "On demand" option won't schedule anything but will allow you to trigger the backup manually or using our API.

  • Define the backup retention, which is the number of backups you want to keep (kind of the history length of your backup if you prefer)

Choose the database you need to backup (C)

  • Select the type of your database, in this case "PostgreSQL"
  • Fill in the database connection form. Note: Backing up all databases on your server at once, requires a paid plan

Finalize and create

  • Pick the name of your backup (this is how it will be displayed in SimpleBackups interface) and where you want to store it.

  • Select your storage (step 3)

That's it, your PostgreSQL backup is now ready. Run it once manually (using the "Run" backup button from the backups list) and you'll trigger your first backup!

FAQ

Can I store PostgreSQL backups in Azure Blob Storage without writing a script?

Yes. Connect the storage account and container once, then pick PostgreSQL as the backup source and Azure as the destination. SimpleBackups runs the dump on your schedule and uploads it, so there is no cron entry or upload script to maintain.

Which Azure credentials does SimpleBackups need?

The storage account name and one of the two access keys found under Settings, Access Keys in the Azure portal. You also supply the container name and the storage endpoint suffix, which is core.windows.net for public Azure regions.

Does the Azure region I pick matter for GDPR?

It does. Backups are stored in the region of the storage account you connect, so an EU company with data residency requirements should create the storage account in an EU region before connecting it.

How do I restore a PostgreSQL backup stored in Azure?

Download the dump from the container and restore it with psql for a plain SQL file or pg_restore for a custom-format archive. The restore guide covers both paths and the errors that come up most often.

Keep learning

Scheduling, retention and restores across every destination are covered on the managed PostgreSQL backup page.


This article is part of The complete guide to PostgreSQL backup, an honest, practical reference from the team that backs up PostgreSQL every day.