NAS backup: automated infrastructure backup (database, configs, certificates)#12900
NAS backup: automated infrastructure backup (database, configs, certificates)#12900jmsperu wants to merge 1 commit into
Conversation
Adds automated backup of CloudStack infrastructure to NAS storage: - MySQL databases (cloud + cloud_usage if enabled) - Management server configuration (/etc/cloudstack/management/) - Agent configuration (/etc/cloudstack/agent/) - SSL certificates and keystores Backup runs daily via BackgroundPollManager, configurable via global settings: - nas.infra.backup.enabled (default: false) - nas.infra.backup.location (NAS mount path) - nas.infra.backup.retention (default: 7 backup sets) - nas.infra.backup.include.usage.db (default: true) Backups are stored in the NAS backup storage under infra-backup/ with automatic retention management. Uses mysqldump --single-transaction for hot database backup (no table locks, InnoDB consistent snapshot). Database credentials are read from /etc/cloudstack/management/db.properties.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12900 +/- ##
============================================
- Coverage 17.61% 17.60% -0.01%
+ Complexity 15676 15674 -2
============================================
Files 5917 5918 +1
Lines 531537 531688 +151
Branches 64985 65008 +23
============================================
- Hits 93610 93608 -2
- Misses 427369 427525 +156
+ Partials 10558 10555 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Code LGTM. However, I wonder whether backing up the CloudStack database from within CloudStack itself is the right approach. In most deployments, database backups are usually handled externally by administrators (e.g., via cron jobs or existing backup tooling). That approach may be simpler and more flexible operationally. |
|
@weizhouapache fair point — the intent here was never to replace external/operational DB backup tooling, but to give small and edge deployments a one-knob "backup the management plane to the same NAS that already holds my VM backups" option for disaster recovery (rebuild from a fresh management server using only what's on the NAS). Concrete adjustments I can make:
Does that split land closer to where you'd want it? |
Summary
Adds a new
InfrastructureBackupTaskto the NAS backup plugin that performs daily backups of CloudStack infrastructure (database, management/agent configs, SSL certs) to NAS storage.Problem
CloudStack's NAS backup provider only backs up VM disks. The management server database, agent configurations, SSL certificates, and global settings are not backed up. If the management server fails, all metadata is lost unless someone manually configured mysqldump cron.
Solution
A new background poll task that automatically backs up:
cloud+ optionallycloud_usage) usingmysqldump --single-transactionfor InnoDB-consistent hot backups/etc/cloudstack/management/)/etc/cloudstack/agent/) if present/etc/cloudstack/management/cert/) if presentDatabase credentials are read from
/etc/cloudstack/management/db.propertiesat runtime (no secrets stored in global config).Configuration
nas.infra.backup.enabledfalsenas.infra.backup.location/mnt/nas-backup)nas.infra.backup.retention7nas.infra.backup.include.usage.dbtruecloud_usagedatabaseBackup Structure
Changes
InfrastructureBackupTask.java- background task implementingBackgroundPollTaskNASBackupProvider.java- added 4 ConfigKeys, scheduled the backup taskTest plan
nas.infra.backup.enabled=trueandnas.infra.backup.location=/mnt/test-backupcloud-*.sql.gzdatabase dump is created and restorablemanagement-config.tar.gzcontains/etc/cloudstack/management/filesagent-config.tar.gzis created only when agent config dir existsdb.propertiesgracefullycloud_usagebackup is included/excluded based on config