Backup and Recovery¶
Target Audience: Administrators Difficulty: Intermediate Prerequisites: Database access; root or sudo access
What to Back Up¶
A complete MultiFlexi backup consists of:
Database — all configuration, jobs, credentials, artifacts, logs
Configuration file —
/etc/multiflexi/multiflexi.envEncryption master key —
ENCRYPTION_MASTER_KEYfrom the env file (critical!)Uploaded application JSON files (if any are stored locally)
Warning
The ENCRYPTION_MASTER_KEY is required to decrypt stored credentials. Without it,
a restored database is useless. Store this key in a separate, secure location.
Database Backup¶
MySQL / MariaDB¶
# Full database dump
mysqldump -u root -p multiflexi > /backup/multiflexi_$(date +%Y%m%d_%H%M%S).sql
# Compressed
mysqldump -u root -p multiflexi | gzip > /backup/multiflexi_$(date +%Y%m%d_%H%M%S).sql.gz
# Non-interactive (using credentials file or .my.cnf)
mysqldump --defaults-file=/etc/mysql/multiflexi-backup.cnf multiflexi > /backup/multiflexi.sql
PostgreSQL¶
# As postgres user
sudo -u postgres pg_dump multiflexi > /backup/multiflexi_$(date +%Y%m%d_%H%M%S).sql
# Compressed
sudo -u postgres pg_dump -Fc multiflexi > /backup/multiflexi_$(date +%Y%m%d_%H%M%S).dump
SQLite¶
# Simple file copy (while services are stopped for consistency)
sudo systemctl stop multiflexi-scheduler multiflexi-executor multiflexi-eventor
cp /var/lib/multiflexi/multiflexi.db /backup/multiflexi_$(date +%Y%m%d_%H%M%S).db
sudo systemctl start multiflexi-scheduler multiflexi-executor multiflexi-eventor
Configuration Backup¶
sudo cp /etc/multiflexi/multiflexi.env /backup/multiflexi.env_$(date +%Y%m%d)
Automating Backups¶
Example cron job (daily at 2:00 AM):
# /etc/cron.d/multiflexi-backup
0 2 * * * root mysqldump -u root multiflexi | gzip > /backup/multiflexi_$(date +\%Y\%m\%d).sql.gz && find /backup -name "multiflexi_*.sql.gz" -mtime +30 -delete
Adjust the retention period (-mtime +30) and backup path to match your policy.
Database Recovery¶
MySQL / MariaDB¶
# Stop services first
sudo systemctl stop multiflexi-scheduler multiflexi-executor multiflexi-eventor
# Drop and recreate database
mysql -u root -p -e "DROP DATABASE multiflexi; CREATE DATABASE multiflexi CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
# Restore
mysql -u root -p multiflexi < /backup/multiflexi_20250101_020000.sql
# Start services
sudo systemctl start multiflexi-scheduler multiflexi-executor multiflexi-eventor
PostgreSQL¶
sudo systemctl stop multiflexi-scheduler multiflexi-executor multiflexi-eventor
sudo -u postgres dropdb multiflexi
sudo -u postgres createdb multiflexi
# Plain SQL restore
sudo -u postgres psql multiflexi < /backup/multiflexi.sql
# Custom format restore
sudo -u postgres pg_restore -d multiflexi /backup/multiflexi.dump
sudo systemctl start multiflexi-scheduler multiflexi-executor multiflexi-eventor
Post-Recovery Checks¶
After restoring:
Verify the configuration file matches the restored database:
cat /etc/multiflexi/multiflexi.envRun pending migrations (in case the backup predates the current schema):
sudo -u multiflexi php /usr/share/multiflexi/vendor/bin/phinx migrate -c /etc/multiflexi/phinx.phpVerify services start cleanly:
sudo systemctl restart multiflexi-scheduler multiflexi-executor multiflexi-eventor systemctl status multiflexi-scheduler multiflexi-executor multiflexi-eventor
Open the web interface and confirm companies, run templates, and credentials are present.
Disaster Recovery Checklist¶
In the event of total system loss:
Install the operating system and add the MultiFlexi APT repository (see Installation Guide)
Install MultiFlexi:
sudo apt install multiflexi-mysql(or your DB variant)Restore
/etc/multiflexi/multiflexi.envincluding theENCRYPTION_MASTER_KEYRestore the database
Install the same credential plugin packages that were previously installed
Restart services
See Also¶
Database Maintenance — Migration and maintenance commands
Upgrading MultiFlexi — Pre-upgrade backup recommendations
Configuration — Encryption key configuration