Registry / aws / mwaa-dr

mwaa-dr

JSON →
library2.2.0pypypiunverified

mwaa-dr is a Python library that provides a reusable framework for implementing disaster recovery solutions for Amazon Managed Workflows for Apache Airflow (MWAA). It simplifies the creation of Airflow DAGs for exporting and importing MWAA metadata, enabling backup and restore capabilities for critical Airflow components like variables, connections, and DAG run history. The library currently supports various MWAA versions, with the latest PyPI release being 2.2.0, and development is ongoing with updates to support newer Airflow versions.

pip install mwaa-dr
INSTALL
IMPORT
SIG · MWAA-DR
M
mwaa-dr
awspythonv2.2.0
Install
2.0s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.0s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DRFactory
from mwaa_dr import DRFactory
from mwaa_dr import DRFactory

This quickstart demonstrates how to use `mwaa-dr` to create a daily metadata backup DAG and a manually triggered restore DAG for an MWAA environment running Apache Airflow 2.10.x. It also shows how to create a cleanup DAG. Before running, ensure you have an S3 bucket configured for backups and the `DR_BACKUP_BUCKET` Airflow variable is set in your MWAA environment. The MWAA execution role must have appropriate S3 permissions.

import os from airflow import DAG from airflow.utils.dates import days_ago from mwaa_dr.v_2_10.dr_factory import DRFactory_2_10 # Ensure DR_BACKUP_BUCKET Airflow Variable is set in your MWAA environment # and MWAA execution role has read/write permissions on it. # Example: DR_BACKUP_BUCKET = 'your-mwaa-backup-bucket' # Initialize the DRFactory for your MWAA/Airflow version # For local testing with aws-mwaa-local-runner, use storage_type='LOCAL_FS' # and create a 'data' folder in your dags directory. factory = DRFactory_2_10( dag_id='backup_metadata_example', path_prefix='data', # Relative path within the S3 bucket or local_fs storage_type='S3' # Or 'LOCAL_FS' for local development ) # Create a backup DAG backup_dag: DAG = factory.create_backup_dag( schedule_interval='@daily', # Example schedule start_date=days_ago(1) ) # Create a restore DAG (typically disabled by default, meant for manual trigger) restore_dag: DAG = factory.create_restore_dag( dag_id='restore_metadata_example', start_date=days_ago(1), is_paused_upon_creation=True # Recommended for restore DAGs ) # Create a cleanup DAG (for emptying metadata tables before restore, use with caution) cleanup_dag: DAG = factory.create_cleanup_dag( dag_id='cleanup_metadata_example', start_date=days_ago(1), is_paused_upon_creation=True # Recommended for cleanup DAGs )
mwaa-dr --version
Debug
Known issues
breakingDirect metadata database access from Airflow workers is being removed in Apache Airflow 3.x. mwaa-dr needs updates to support Airflow 3.0.
fix
Monitor the `mwaa-dr` GitHub repository for updates and official support for Airflow 3.0. Ensure your Airflow environment is on version 2.10.x for the best compatibility path to future Airflow 3.x upgrades.
affects: MWAA versions supporting Airflow 3.0 and above
gotchaThe import path for `DRFactory` is version-specific to your MWAA/Airflow environment. Using the wrong version (e.g., `DRFactory_2_5` for an Airflow 2.10.3 environment) will lead to import errors or unexpected behavior.
fix
Always import `DRFactory_X_Y` where `X_Y` matches your exact MWAA/Airflow environment version (e.g., `from mwaa_dr.v_2_10.dr_factory import DRFactory_2_10` for MWAA 2.10.x). The supported versions are listed in the `mwaa-disaster-recovery` GitHub README.
affects: All versions
gotchaFor metadata restore to work correctly, the target database usually needs to be empty to avoid foreign key constraint violations. The solution provides a `cleanup_metadata` DAG for this purpose, which should be used with extreme caution.
fix
Always use the `cleanup_metadata` DAG (created via `factory.create_cleanup_dag()`) to clear the target MWAA metadata tables *before* running a restore. Ensure this DAG is paused upon creation and triggered manually only when necessary. Review the tables backed up by default and consider overriding `dr_factory.setup_tables()` for custom table sets.
affects: All versions
gotchaAirflow variables `DR_VARIABLE_RESTORE_STRATEGY` and `DR_CONNECTION_RESTORE_STRATEGY` control how variables and connections are restored. Incorrect settings can lead to unintended overwrites or data loss, especially if using AWS Secrets Manager.
fix
Set these Airflow variables to `DO_NOTHING`, `APPEND`, or `REPLACE` based on your disaster recovery strategy. If using AWS Secrets Manager for variables/connections, set them to `DO_NOTHING` to prevent `mwaa-dr` from restoring from S3 backup.
affects: All versions
Upgrade
Version history
2.2.0latest on PyPI · released Mar 30, 2026
Audit
Dependencies
apache-airflowrequiredThis library generates DAGs for Apache Airflow within an MWAA environment.
Agent activity
28 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
mwaa-dr — pip install mwaa-dr · libregistry