Backup & Restore
Backup scripts and data recovery
Back up your video library, database, and config regularly. Do this before upgrades and after big uploads.
Automated backup
cd nixstream/nixstream
./scripts/backup.shThe backup script captures database dumps and relevant application data. Schedule it via cron for regular backups:
0 2 * * * cd /path/to/core && ./scripts/backup.sh >> /var/log/nixstream-backup.log 2>&1Run at least daily for active installs. Store backups off-server (S3, another machine, or backup service).
What to back up
| Component | Location | Priority |
|---|---|---|
| Database | MySQL dump | Critical |
| Encoded media | storage/app/public/videos/ | Critical |
| Uploads in progress | storage/app/ | High |
| Configuration | .env | Critical (store encrypted, separately) |
| Whisper models | bin/whisper/models/ or Docker image | Medium (re-downloadable) |
Database dump manually
docker compose exec db mysqldump -u nixstream_user -p nixstream > backup.sqlManual install:
mysqldump -u nixstream_user -p nixstream > backup.sqlStorage archive
tar -czf storage-backup.tar.gz storage/app/public/videos/For S3-backed storage, use provider-native backup (versioning, cross-region replication) in addition to database backups.
Docker volumes
Docker Compose uses named volumes for db and storage:
docker volume ls | grep nixstream
docker volume inspect nixstream_storage_dataVolume data survives container restarts but not docker volume rm. Include volumes in your backup strategy or use bind mounts to host paths for easier file-level backup.
Restore procedure
- Stop services:
./install.sh --down - Restore database dump to MySQL
- Restore
storage/files to the correct path - Restore
.env(or verify settings match the backup era) - Start services:
./install.sh - Run migrations if upgrading:
php artisan migrate --force - Verify a sample video plays and API responds
Restore database (Docker)
docker compose up -d db
docker compose exec -T db mysql -u nixstream_user -p nixstream < backup.sqlRestore storage
tar -xzf storage-backup.tar.gz -C /path/to/nixstream/nixstream/
chown -R www-data:www-data storage/Migrations
Run database migrations after upgrades:
cd nixstream/nixstream
./scripts/migrate.sh
# or
docker compose exec app php artisan migrate --forceAlways back up before migrating production databases.
Testing restores
Test restores quarterly on a staging server:
- Restore latest backup to a clean machine
- Confirm admin login works
- Play a random video
- Check API key authentication
Untested backups are a gamble.
Reset (destructive)
./install.sh --resetDeletes all database data and Docker volumes. Use only in development.
Disaster recovery checklist
Provision a host that meets Requirements, install NixStream, restore .env (update APP_URL if the domain moved), restore the database dump and storage (or re-point S3 credentials), swing DNS, re-issue SSL, then confirm queue workers and live ingest.
Disk layout: Storage. Day-to-day checks: Monitoring. Upgrade notes: Changelog.