-
Notifications
You must be signed in to change notification settings - Fork 3
Data Anonymization
Griffen Fargo edited this page Jun 30, 2026
·
2 revisions
strut can anonymize PII when syncing production databases to local development environments. This helps teams comply with GDPR, HIPAA, and other data protection requirements.
# 1. Configure anonymization rules
nano stacks/my-stack/anonymize.conf
# 2. Sync with anonymization
strut my-stack local sync-db --from prod --anonymizeCreate stacks/<stack>/anonymize.conf with rules in TABLE.COLUMN=strategy format:
# anonymize.conf — PII anonymization rules
users.email=fake_email
users.name=fake_name
users.phone=null
orders.address=fake_address
payments.card_number=mask
sessions.token=hash
users.id=preserveThis file is automatically scaffolded (commented out) when you run strut scaffold.
| Strategy | What it does | Example |
|---|---|---|
fake_email |
Replace with user_<id>@example.com
|
john@real.com → user_42@example.com
|
fake_name |
Replace with User <id>
|
John Smith → User 42
|
null |
Set column to NULL |
555-1234 → NULL
|
mask |
Keep first/last char, mask middle |
4111222233334444 → 4***4
|
hash |
SHA256 hash on Postgres/MySQL; hex-encoding (HEX()) on SQLite, which lacks built-in SHA256 (preserves uniqueness) |
john@real.com → a1b2c3d4...
|
fake_address |
Replace with generic address |
123 Main St → 42 Test Avenue
|
preserve |
Keep original value (no-op) | Use for non-PII columns |
-
sync-dbdownloads the production database dump from VPS - The dump is restored to the local database
- Anonymization SQL (
UPDATEstatements) is applied after restore - Each rule generates a database-specific SQL statement
The engine supports Postgres, MySQL, and SQLite — it generates the correct SQL syntax for each.
Preview which columns would be anonymized without making changes:
DRY_RUN=true strut my-stack local sync-db --from prod --anonymizeOutput:
[DRY-RUN] Anonymization plan:
[DRY-RUN] users.email → fake_email
[DRY-RUN] users.name → fake_name
[DRY-RUN] users.phone → null
3 rule(s) would be applied
[DRY-RUN] No changes made.
strut warns you when:
-
anonymize.confexists but--anonymizewas not passed — reminds you to anonymize -
--anonymizeis passed but noanonymize.confexists — tells you to create one
# Scaffold a new stack (includes anonymize.conf template)
strut scaffold my-app
# Edit anonymize.conf with your PII columns
cat > stacks/my-app/anonymize.conf <<'EOF'
users.email=fake_email
users.full_name=fake_name
users.phone_number=null
users.address=fake_address
payments.card_number=mask
api_keys.secret=hash
EOF
# Sync production data with anonymization
strut my-app local sync-db --from prod --anonymize
# Verify — no real PII in local database
strut my-app local debug exec postgres "psql -U postgres -c 'SELECT email, full_name FROM users LIMIT 5;'"
# user_1@example.com | User 1
# user_2@example.com | User 2
# ...- Local Development — full local dev workflow
- Database Backups — backup and restore commands
- Configuration — strut.conf and per-stack config files
strut · v0.28.0 · Report an Issue
Getting Started
Core Concepts
Operations
- Deployment
- Ship and Rebuild
- GitHub Action
- Webhook Automation
- Remote Host Setup
- Provisioning
- Blue-Green Deploy
- Deploy Rollback
- Database Backups
- Secrets Management
- Stack Groups
- Lifecycle Hooks
- Notifications
- Key Rotation
- Drift Detection
- Domain and SSL
- Certificate Management
- Gateway Management
- Monitoring
- Volume Management
Advanced
- Security Posture
- VPS Audit and Migration
- Stack Validation
- Data Anonymization
- Debugging
- Local Development
Extending
Contributing