This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Commit f13b08d
committed
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.1 parent 1f49a67 commit f13b08d
File tree
6 files changed
+118
-51
lines changed- application
- infrastructure
- cloud-init
- docs/refactoring/multi-provider-abstraction
- scripts
- terraform
6 files changed
+118
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
109 | 125 | | |
110 | 126 | | |
111 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
| |||
Lines changed: 29 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | | - | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| |||
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
190 | | - | |
191 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
| |||
271 | 276 | | |
272 | 277 | | |
273 | 278 | | |
274 | | - | |
| 279 | + | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
| |||
519 | 525 | | |
520 | 526 | | |
521 | 527 | | |
522 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
523 | 531 | | |
524 | 532 | | |
525 | 533 | | |
| |||
668 | 676 | | |
669 | 677 | | |
670 | 678 | | |
671 | | - | |
672 | | - | |
673 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
674 | 682 | | |
675 | 683 | | |
676 | 684 | | |
677 | | - | |
678 | | - | |
| 685 | + | |
| 686 | + | |
679 | 687 | | |
680 | 688 | | |
681 | 689 | | |
682 | | - | |
683 | | - | |
| 690 | + | |
| 691 | + | |
684 | 692 | | |
685 | 693 | | |
686 | 694 | | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
694 | 702 | | |
695 | 703 | | |
696 | 704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
358 | 371 | | |
359 | 372 | | |
360 | 373 | | |
| |||
371 | 384 | | |
372 | 385 | | |
373 | 386 | | |
374 | | - | |
| 387 | + | |
375 | 388 | | |
376 | 389 | | |
377 | 390 | | |
| |||
397 | 410 | | |
398 | 411 | | |
399 | 412 | | |
400 | | - | |
| 413 | + | |
401 | 414 | | |
402 | 415 | | |
403 | 416 | | |
| |||
447 | 460 | | |
448 | 461 | | |
449 | 462 | | |
450 | | - | |
| 463 | + | |
451 | 464 | | |
452 | 465 | | |
453 | 466 | | |
| |||
463 | 476 | | |
464 | 477 | | |
465 | 478 | | |
466 | | - | |
| 479 | + | |
467 | 480 | | |
468 | 481 | | |
469 | 482 | | |
| |||
474 | 487 | | |
475 | 488 | | |
476 | 489 | | |
477 | | - | |
| 490 | + | |
478 | 491 | | |
479 | 492 | | |
480 | 493 | | |
| |||
483 | 496 | | |
484 | 497 | | |
485 | 498 | | |
486 | | - | |
| 499 | + | |
487 | 500 | | |
488 | 501 | | |
489 | 502 | | |
| |||
502 | 515 | | |
503 | 516 | | |
504 | 517 | | |
505 | | - | |
| 518 | + | |
506 | 519 | | |
507 | 520 | | |
508 | 521 | | |
509 | | - | |
| 522 | + | |
510 | 523 | | |
511 | 524 | | |
512 | 525 | | |
513 | 526 | | |
514 | | - | |
| 527 | + | |
515 | 528 | | |
516 | 529 | | |
517 | 530 | | |
| |||
527 | 540 | | |
528 | 541 | | |
529 | 542 | | |
530 | | - | |
| 543 | + | |
531 | 544 | | |
532 | 545 | | |
533 | 546 | | |
| |||
592 | 605 | | |
593 | 606 | | |
594 | 607 | | |
595 | | - | |
596 | | - | |
| 608 | + | |
| 609 | + | |
597 | 610 | | |
598 | 611 | | |
599 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
88 | 107 | | |
89 | 108 | | |
90 | 109 | | |
| |||
117 | 136 | | |
118 | 137 | | |
119 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
120 | 144 | | |
121 | 145 | | |
122 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
0 commit comments