The Simplest Way to Make AWS Backup and Luigi Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair aws backup and luigi to take safe data snapshots before batch jobs run. Luigi orders the tasks while AWS Backup saves cloud storage states on demand. Data teams run many batch jobs every night. A bad job can break tables or delete good files. When you trigger a backup task first, you build a safe recovery point. If a later step fails, your team can restore the data fast. This setup keeps production databases safe during heavy batch writes. How roles and data flow between aws backup

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair aws backup and luigi to take safe data snapshots before batch jobs run. Luigi orders the tasks while AWS Backup saves cloud storage states on demand.

Data teams run many batch jobs every night. A bad job can break tables or delete good files. When you trigger a backup task first, you build a safe recovery point. If a later step fails, your team can restore the data fast. This setup keeps production databases safe during heavy batch writes.

How roles and data flow between aws backup and luigi

Luigi runs as a Python worker on a server or container. It builds a graph of tasks and checks what needs to run. To start a backup, a Luigi task calls the AWS API. The worker needs an AWS role to make this call.

You should attach an IAM role to the host that runs Luigi. This role grants permission to start backup jobs and check their status. AWS Backup also needs its own service role to read the target database. Luigi never reads the raw database bytes during the backup step. Instead, Luigi sends a start request and waits for a job ID.

In Luigi, every task must write a target marker when it finishes. For a backup task, you can write the recovery point ID to storage. You can also use a custom target that checks the AWS job status. The task polls AWS until the backup state changes to complete. Once the backup finishes, Luigi starts the next data transform task.

Common failure modes and how to scope roles

Many teams make the mistake of using one broad AWS key for all tasks. If a developer logs into the worker host, they can take that key. A broad key often lets anyone delete backups or read secret tables. Unlogged API calls also make it hard to track who started a restore.

You can fix this by splitting roles by task type. Give the Luigi host role permission to start backups on specific resources only. Never give the worker role permission to delete recovery points or vaults. Put your backup vaults in a separate account or lock them with strict rules.

AWS IAM Policies + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Network paths between the worker and cloud APIs also need tight rules. Run your Luigi workers inside a private subnet with no public IP. Use private VPC endpoints so API traffic stays inside the cloud network. Log every backup request in CloudTrail so your security team can review them.

Managing task retries and long backup windows

Backups of large databases can take hours to finish. If a Luigi worker waits in a loop, it holds up a worker slot. If the worker restarts, the task might trigger a second backup by mistake. This wastes storage space and slows down your database.

To prevent double backups, pass an idempotency token when the task starts. If Luigi retries the task, AWS returns the same job ID. You can also split the start request and the status check into two tasks. This lets the worker free up slots while AWS copies the data. When teams query restored data for tests, data masking rewrites emails and phone numbers.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

How does Luigi know when an AWS Backup job finishes?

The Luigi task polls the AWS API using the backup job ID. When the job status reaches completed, the task marks its target as done.

What permissions does the Luigi worker role need?

The worker role needs permission to start a backup job and describe backup jobs. It also needs permission to pass the backup service role to AWS Backup.

How do we stop Luigi from starting duplicate backups on retry?

Check for running backup jobs on the resource before sending a new start call. You can also store the active job ID in a local state file.

The query runs. The emails stay hidden.