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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibcpy 3.10–3.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.fixMonitor 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.fixAlways 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.fixAlways 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.fixSet 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.