Back to Blocks
PXL-829Done
No priority

Implement automated daily Supabase backup system

Labels
data1-circebackupsyncFeature

Summary

Implemented an automated daily backup system that exports all NutriKit Supabase database tables to GitHub for disaster recovery and data protection.

Documentation

What was implemented

Components

  • Vercel Cron Job: Runs daily at 3 AM UTC via /api/backup endpoint
  • Backup API (app/api/backup/route.ts): Fetches all tables with pagination, filters sensitive data, compresses with gzip, uploads to GitHub
  • GitHub Repository: https://github.com/pxlshpr/nutrikit-backups (public)

Tables backed up

TableRowsCompressed Size
users74~3 KB
foods7,006~2.5 MB
preferences43~3 KB
days863~139 KB
meals1,952~456 KB
meal_items5,301~1.4 MB
user_foods564~39 KB
meal_presets0~22 bytes

Total: ~4.5 MB per backup

Security

  • Sensitive fields excluded: apple_user_id, cloudkit_id, device_ids
  • Authenticated via Bearer token (CRON_SECRET)
  • Uses Supabase service role key to bypass RLS

Retention policy

  • Last 30 days: Keep all daily backups
  • 30-90 days: Keep 1 per week
  • 90+ days: Keep 1 per month

Cost

$0/month (all free tiers)


Completed: 2026-01-02

Created Jan 2, 2026, 5:28 PM · Updated Jan 6, 2026, 12:45 PM