Zero-friction DB snapshots for Rails development. Auto-captures before migrations, so you can undo anything.
curl -sSL https://raw.githubusercontent.com/ikraamg/devsnap/main/devsnap.rake \
-o lib/tasks/devsnap.rake && echo ".snapshots/" >> .gitignoreThat's it. Next time you run rails db:migrate, it auto-snapshots first.
It just works:
rails db:migrate # Auto-snapshots before migratingManual commands:
rails devsnap:list # See your snapshots
rails devsnap:capture[name] # Manual snapshot
rails devsnap:restore[name] # Restore snapshot- Ruby 3.2+ (actively supported versions)
- Rails 7.0+ (actively supported versions)
- PostgreSQL (any version)
- Development environment only
All optional via environment variables:
DEVSNAP=off- Disable for one commandDEVSNAP_KEEP=10- Number of snapshots to keep (default: 5)DEVSNAP_MAX_MB=1000- Max DB size in MB (default: 500)FORCE_SNAP=1- Ignore size limit
# Skip auto-snapshot for this migration
DEVSNAP=off rails db:migrate
# Keep more snapshots
DEVSNAP_KEEP=10 rails db:migrate
# Force snapshot of large database
FORCE_SNAP=1 rails devsnap:capture[before_risk]
# Restore from yesterday
rails devsnap:list
rails devsnap:restore[20240123_143022]rm lib/tasks/devsnap.rake
rm -rf .snapshots/- Hooks into
db:migratein development only - Before running pending migrations, captures DB with
pg_dump -Fc - Names snapshots with timestamp:
pre_migrate_1708789234.dump - Auto-prunes old snapshots (keeps last 5)
- Skips large databases (>500MB) automatically
- Silent operation - doesn't disrupt your workflow
MIT