You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
feat: [#14] implement persistent data volume for VM data persistence
This commit implements a dedicated 20GB persistent data volume that survives
VM destruction, ensuring critical application data is preserved across
infrastructure changes.
## Infrastructure Changes
**Terraform Configuration:**
- Add variable (default: 20GB)
- Add resource
- Attach persistent volume as second disk to VM
**Cloud-init Configuration:**
- Add disk setup for with GPT partition table
- Add ext4 filesystem creation with 'torrust-data' label
- Add automatic mount to with noatime option
- Add directory structure creation and ownership setup
## Application Changes
**Docker Compose Volume Mounts:**
- Replace all `./storage/` paths with `/var/lib/torrust/` direct mounts
- Remove symlink complexity for cleaner, more explicit configuration
- Maintain same container functionality with persistent storage
**Deployment Script Updates:**
- Replace symlink creation with direct directory structure setup
- Update all docker compose commands to use `--env-file /var/lib/torrust/compose/.env`
- Add comprehensive persistent storage directory creation
- Preserve existing .env files during deployment
## Data Persistence Benefits
**What Survives VM Destruction:**
- MySQL database (tracker data, user accounts, statistics)
- Environment configuration (.env file with passwords/tokens)
- Prometheus metrics (historical monitoring data)
- Tracker logs and state
- SSL certificates (when configured)
- All application persistent data
**What Gets Refreshed:**
- Application code (deployed fresh from git)
- System configuration (VM rebuilt from cloud-init)
- Docker images (pulled fresh)
## Architecture Improvements
**Twelve-Factor Compliance:**
- Clean separation between infrastructure (Build) and application (Release/Run)
- Configuration persists while code is deployed fresh
- Maintains stateless application design with persistent data store
**Filesystem Hierarchy Standard:**
- Uses `/var/lib/torrust` for application persistent data
- Follows Linux FHS conventions for service data storage
- Clear separation between transient and persistent data
## Testing
- All infrastructure tests pass
- Docker Compose syntax validation passes
- End-to-end deployment tests successful
- Persistent data preservation verified across VM recreations
This implementation provides production-ready data persistence while
maintaining the clean twelve-factor architecture and deployment workflow.
0 commit comments