Skip to content

Conversation

@xrendan
Copy link
Member

@xrendan xrendan commented Oct 3, 2025

Summary

  • Adds automated weekly database dumps to GitHub artifacts
  • Provides rake tasks for easy database restoration
  • Streamlines developer onboarding with production data

Features

Automated Database Dumps

  • Runs weekly every Monday at 2 AM UTC via GitHub Actions
  • Uses PostgreSQL's custom archive format (.dump) for efficient storage
  • Excludes sensitive data (users table) for privacy/security
  • Automatically cleans up dumps older than 28 days

Restore Functionality

  • rake db:list_dumps - Lists available database dump artifacts
  • rake db:fetch_and_restore - Downloads and restores latest dump
  • rake db:restore[dump_file] - Restores from a specific dump file

Technical Details

  • Uses PostgreSQL 17 client to match production version
  • Implements modern apt keyring method (fixes deprecation warning)
  • Caches PostgreSQL installation for faster workflow runs
  • Uses GitHub CLI for artifact downloads (required due to API limitations)

Setup Required

  1. Add DATABASE_URL secret in repository settings for production database access
  2. Developers need GitHub CLI (gh) installed and authenticated

Test Plan

  • Verify workflow runs successfully on schedule
  • Confirm database dump excludes users table
  • Test restore process with rake db:fetch_and_restore
  • Verify README documentation is clear for new developers

🤖 Generated with Claude Code

xrendan added 10 commits October 2, 2025 17:01
- Install PostgreSQL 17 client to match server version
- Uses official PostgreSQL APT repository
- Fixes pg_dump version mismatch error
- Simplifies artifact upload using official GitHub Action
- More reliable than direct API calls
- Maintains same functionality with cleaner implementation
- Use pg_dump custom format (.dump) instead of plain SQL
- Add rake db:fetch_and_restore to download and restore latest dump
- Add rake db:restore to restore from a specific dump file
- Add rake db:list_dumps to list available dump artifacts
- Requires GITHUB_TOKEN or GITHUB_PAT environment variable
- Replace deprecated apt-key with signed-by keyring method
- Add GitHub Actions cache for PostgreSQL client installation
- Cache will speed up subsequent workflow runs
- Rake tasks no longer require GITHUB_TOKEN for public repositories
- Handle redirect when downloading artifacts
- Add better error messages for expired/private artifacts
- Document database restore process for new developers
- Explain weekly backup schedule and retention
- Include quick start commands for fetching production data
- Note PostgreSQL version requirements
- Switch to gh CLI for downloading artifacts
- Add prerequisite check for gh installation
- Update documentation to reflect gh CLI requirement
- GitHub API requires authentication even for public repos
- Use gpg --dearmor to convert ASCII armored key to binary format
- Add gnupg package dependency
- Create keyrings directory if missing
- Fixes 'NO_PUBKEY' error during apt update
@xrendan xrendan merged commit 3a40fb3 into main Oct 7, 2025
2 of 3 checks passed
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.

2 participants