Add db:export and db:import for database backups

Made-with: Cursor
This commit is contained in:
Michilis
2026-03-07 19:44:27 +00:00
parent 7c1fdbf382
commit 2f45966932
5 changed files with 214 additions and 2 deletions

View File

@@ -64,6 +64,8 @@ npm run start
npm run db:generate
npm run db:migrate
npm run db:studio
npm run db:export # Backup database
npm run db:import # Restore from backup
```
You can also run per workspace:
@@ -117,6 +119,25 @@ Then run:
npm run db:migrate
```
### Backups (export / import)
Create backups and restore if needed:
```bash
# Export (creates timestamped file in backend/data/backups/)
npm run db:export
# Export to custom path
npm run db:export -- -o ./my-backup.db # SQLite
npm run db:export -- -o ./my-backup.sql # PostgreSQL
# Import (stop the backend server first)
npm run db:import -- ./data/backups/spanglish-2025-03-07-143022.db
npm run db:import -- --yes ./data/backups/spanglish-2025-03-07.sql # Skip confirmation
```
**Note:** Stop the backend before importing so the database file is not locked.
## Production deployment (nginx + systemd)
This repo includes example configs in `deploy/`: