Add db:export and db:import for database backups
Made-with: Cursor
This commit is contained in:
21
README.md
21
README.md
@@ -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/`:
|
||||
|
||||
Reference in New Issue
Block a user