menu_book Navigation menu

Disaster Recovery (backup.sh)

Overview

Backups are critical for production systems. The backup.sh script handles both SQL dumps and file archiving. It is designed to be lean: it explicitly ignores ephemeral data (cache, temporary files) to save disk space and reduce I/O overhead.

Execution

This script is automatically registered in the Crontab during server installation to run daily at 03:00 AM.

You can trigger it manually at any time:

BASH
sudo bash /var/www/pragma-cms/scripts/cron/backup.sh

Architecture & Logic

  • Intelligent Database Dumps: Instead of dumping a single massive SQL file, the script queries MariaDB for all existing databases (ignoring system schemas like information_schema and mysql). It generates a separate .sql.gz file for each tenant site. This makes restoring a single client incredibly fast.
  • Selective File Archiving: It creates a tar.gz archive of the CMS root, but strictly excludes /storage/cache/*, /storage/logs/*, and /storage/tmp/*.
  • Retention Policy: By default, the script cleans up after itself. Any backup archive older than 7 days is automatically deleted (find ... -mtime +7 -delete).