160 lines
4.7 KiB
Markdown
160 lines
4.7 KiB
Markdown
# IGNY8 Application Packaging & Backup - Setup Complete ✅
|
||
|
||
## What Was Created
|
||
|
||
### 1. Packaging Script
|
||
**File**: `/data/app/igny8/scripts/package_app.sh`
|
||
- ✅ Creates portable application packages
|
||
- ✅ Excludes all generated artifacts (node_modules, .venv, dist, logs, etc.)
|
||
- ✅ Generates SHA256 checksums for verification
|
||
- ✅ Auto-cleans old backups (7+ days)
|
||
- ✅ Package size: ~44 MB (compressed from ~56 MB source)
|
||
|
||
### 2. Automated Backup Tasks
|
||
**File**: `/data/app/igny8/backend/igny8_core/tasks/backup.py`
|
||
- ✅ `backup.create_daily_app_package` - Daily backup task
|
||
- ✅ `backup.cleanup_old_packages` - Weekly cleanup task
|
||
- ✅ Full error handling and logging
|
||
|
||
### 3. Celery Beat Schedule
|
||
**File**: `/data/app/igny8/backend/igny8_core/celery.py`
|
||
- ✅ Daily backup at 00:00 UTC
|
||
- ✅ Weekly cleanup on Mondays at 01:00 UTC
|
||
|
||
### 4. Documentation
|
||
- ✅ `/data/app/igny8/INSTALLATION.md` - Complete installation guide
|
||
- ✅ `/data/app/igny8/docs/BACKUP-SYSTEM.md` - Backup system documentation
|
||
|
||
## First Backup Created
|
||
|
||
```
|
||
📦 Package: /data/backups/igny8/igny8-app-20251210_161527.tar.gz
|
||
📏 Size: 44 MB
|
||
🔐 SHA256: 5aa8fe458bcb75d1f4a455746a484015a81147bbfa8e8b1285e99195e2deacbd
|
||
```
|
||
|
||
## How It Works
|
||
|
||
### Automatic Daily Backups (00:00 UTC)
|
||
1. Celery Beat triggers `backup.create_daily_app_package` at midnight
|
||
2. Task executes `/data/app/igny8/scripts/package_app.sh`
|
||
3. Script creates compressed archive with date stamp
|
||
4. Package saved to `/data/backups/igny8/`
|
||
5. SHA256 checksum file generated
|
||
6. Old backups (7+ days) auto-deleted
|
||
|
||
### What Gets Packaged
|
||
**INCLUDED** (~56 MB source):
|
||
- `backend/igny8_core/` - All Django code
|
||
- `backend/manage.py`, `requirements.txt`
|
||
- `frontend/src/`, `public/` - All React code
|
||
- `frontend/package.json`, build configs
|
||
- `docs/`, `README.md`
|
||
- Dockerfiles, docker-compose files
|
||
|
||
**EXCLUDED** (auto-generated):
|
||
- `node_modules/` - NPM dependencies (297 MB)
|
||
- `.venv/` - Python virtual environment (140 MB)
|
||
- `dist/` - Build outputs
|
||
- `*.sql`, `*.sqlite3` - Databases
|
||
- `logs/` - Runtime logs
|
||
- Cache files, compiled files
|
||
|
||
### Restoration Process
|
||
```bash
|
||
# On new server:
|
||
1. Extract: tar -xzf igny8-app-YYYYMMDD_HHMMSS.tar.gz
|
||
2. Verify: sha256sum -c igny8-app-YYYYMMDD_HHMMSS.tar.gz.sha256
|
||
3. Follow INSTALLATION.md to deploy
|
||
```
|
||
|
||
## Testing & Verification
|
||
|
||
### Manual Test (Already Done ✅)
|
||
```bash
|
||
/data/app/igny8/scripts/package_app.sh
|
||
# Result: Package created successfully at /data/backups/igny8/
|
||
```
|
||
|
||
### Verify Celery Tasks
|
||
```bash
|
||
# Restart Celery to load new tasks
|
||
docker restart igny8_celery_worker igny8_celery_beat
|
||
|
||
# Check scheduled tasks
|
||
docker exec igny8_celery_beat celery -A igny8_core inspect scheduled
|
||
|
||
# View Beat logs
|
||
docker logs igny8_celery_beat
|
||
|
||
# Manually trigger backup (for testing)
|
||
docker exec igny8_celery_worker celery -A igny8_core call backup.create_daily_app_package
|
||
```
|
||
|
||
### Monitor Backups
|
||
```bash
|
||
# List all backups
|
||
ls -lh /data/backups/igny8/
|
||
|
||
# Check latest backup
|
||
ls -lt /data/backups/igny8/ | head -3
|
||
|
||
# Verify checksum
|
||
cd /data/backups/igny8/
|
||
sha256sum -c igny8-app-*.tar.gz.sha256
|
||
```
|
||
|
||
## Next Steps
|
||
|
||
1. **Wait for first automated backup** (will run at 00:00 UTC tonight)
|
||
2. **Verify backup runs successfully**:
|
||
```bash
|
||
# Check tomorrow morning
|
||
ls -lt /data/backups/igny8/
|
||
```
|
||
3. **Optional: Add remote backup** (copy to S3, Google Drive, etc.)
|
||
|
||
## Retention Policy
|
||
|
||
- **Packaging script**: Deletes backups > 7 days old
|
||
- **Cleanup task**: Deletes backups > 30 days old (weekly check)
|
||
- **Result**: 7-30 days of backups retained automatically
|
||
|
||
## Package Portability
|
||
|
||
✅ **Portable** - Package contains only source code
|
||
✅ **Small** - 44 MB compressed (vs ~500+ MB with dependencies)
|
||
✅ **Clean** - No generated files, logs, or secrets
|
||
✅ **Verified** - SHA256 checksum ensures integrity
|
||
✅ **Self-contained** - Everything needed to rebuild app
|
||
|
||
## Deployment to New Server
|
||
|
||
From the package, you get a clean IGNY8 installation:
|
||
|
||
1. Extract package (44 MB)
|
||
2. Install Docker
|
||
3. Build images (Docker installs dependencies automatically)
|
||
4. Start services
|
||
5. Initialize database
|
||
6. **Ready to run!**
|
||
|
||
**Dependencies installed automatically by Docker**:
|
||
- Python packages from `requirements.txt`
|
||
- Node packages from `package.json`
|
||
- PostgreSQL, Redis containers
|
||
- All build tools and dependencies
|
||
|
||
## Summary
|
||
|
||
✅ **Automated daily backups** at midnight
|
||
✅ **Portable packages** - only source code
|
||
✅ **Auto-cleanup** - keeps 7-30 days
|
||
✅ **Checksum verification** - ensures integrity
|
||
✅ **Easy restoration** - extract and deploy
|
||
✅ **Documentation** - complete guides created
|
||
|
||
**Total disk usage for backups**: ~44 MB × 7-30 days = **308 MB - 1.3 GB**
|
||
|
||
Much better than storing everything (would be 10+ GB with node_modules, venv, etc.)!
|