Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 24, 2025

  • add backup.sh for schema, RLS, functions, triggers, extensions, full data dump
  • add restore.sh for complete database recreation
  • add scheduled GitHub Action (daily 2 AM IST backups)
  • configure .gitignore for SQL snapshots and dump exclusions
  • include initial snapshot directory and documentation

Summary by CodeRabbit

  • New Features

    • Added automated daily database backups for disaster recovery
    • Implemented one-click restore functionality to recover from database incidents
    • Backup artifacts automatically retained for 30 days
  • Documentation

    • Added comprehensive disaster recovery guide with setup instructions, configuration options, troubleshooting guidance, and security best practices

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 24, 2025 5:03pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new Supabase disaster recovery system is introduced, comprising an automated GitHub Actions workflow that triggers daily backups, shell scripts for backup and restore operations, comprehensive documentation, and .gitignore updates to manage backup artifacts.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/backup.yml
Defines a daily scheduled backup job (and manual dispatch) that checks out the repo, installs PostgreSQL tools, executes the backup script, uploads artifacts with 30-day retention, commits SQL files and metadata, and generates a job summary with backup details.
Backup & Restore Scripts
backup.sh, restore.sh
Adds two complementary shell scripts: backup.sh exports database extensions, schema, RLS policies, functions, triggers, and full/seed data with colorized logging; restore.sh performs sequential restoration from backup files with prerequisites validation, user confirmation, connectivity testing, and post-restore verification.
Documentation
supabase_snapshot/README.md
Comprehensive guide covering system features, directory structure, quick-start setup, GitHub Actions configuration, seed data customization, troubleshooting, security best practices, and disaster recovery procedures.
Configuration
.gitignore
Adds ignore rule for .dump files and creates an exception to track SQL files under the supabase_snapshot/ directory.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GHA as GitHub Actions
    participant Backup as backup.sh
    participant DB as Supabase DB
    participant Artifact as Artifacts
    participant Git as Git Repo

    GHA->>GHA: Daily trigger (cron) or manual dispatch
    GHA->>Backup: Execute with SUPABASE_DB_URL
    
    Backup->>Backup: Validate prerequisites & tools
    Backup->>Backup: Create supabase_snapshot/ dir
    
    rect rgb(220, 240, 255)
    Note over Backup,DB: Sequential exports
    Backup->>DB: Export extensions
    Backup->>DB: Export schema (filtered)
    Backup->>DB: Export RLS policies
    Backup->>DB: Export functions & triggers
    Backup->>DB: Export full data (pg_dump binary)
    end
    
    alt Optional seed data configured
        Backup->>DB: Export seed data tables
    end
    
    Backup->>Backup: Generate backup_info.txt metadata
    Backup->>GHA: Return success
    
    GHA->>Artifact: Upload supabase_snapshot/ (30-day retention)
    GHA->>Git: Commit SQL files + backup_info.txt (if changes exist)
    GHA->>GHA: Generate & append job summary
Loading
sequenceDiagram
    autonumber
    participant User
    participant Restore as restore.sh
    participant DB as Supabase DB
    participant Files as Backup Files

    User->>Restore: Execute with SUPABASE_DB_URL
    
    Restore->>Restore: Validate prerequisites & tools
    Restore->>Files: Check backup files exist
    Restore->>User: Prompt for confirmation
    User->>Restore: Confirm restore
    
    Restore->>DB: Test connection
    
    rect rgb(220, 240, 255)
    Note over Restore,DB: Sequential restoration
    Restore->>Files: Read extensions file
    Restore->>DB: Apply extensions
    
    Restore->>Files: Read schema file
    Restore->>DB: Apply schema & objects
    
    Restore->>Files: Read data dump
    Restore->>DB: Restore full data
    
    Restore->>Files: Read functions & triggers
    Restore->>DB: Apply functions & triggers
    
    Restore->>Files: Read RLS policies
    Restore->>DB: Apply RLS policies
    end
    
    Restore->>DB: Verify table count & data presence
    Restore->>User: Report restore status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas requiring extra attention:

  • backup.sh & restore.sh: Database query logic for schema exclusions, extension handling, and data export/import—verify SQL correctness and that filtering rules match intended scope
  • GitHub Actions workflow: Artifact naming, retention policies, conditional commit logic, and error handling edge cases (e.g., failed backup still triggering artifacts upload)
  • .gitignore logic: Confirm that the .dump ignore and !supabase_snapshot/*.sql exception work as intended without unintended file leakage
  • Seed data export configuration: Ensure the optional seed data feature is properly documented and that defaults are sensible

Poem

🐰 A backup a day keeps disasters away,
Scripts running nightly, restoring at day,
With seeds and extensions tucked safely in place,
We hop through recovery at a remarkable pace! 🌱✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/supabase-disaster-recovery-system

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 669a01b and 04ab995.

📒 Files selected for processing (5)
  • .github/workflows/backup.yml (1 hunks)
  • .gitignore (1 hunks)
  • backup.sh (1 hunks)
  • restore.sh (1 hunks)
  • supabase_snapshot/README.md (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants