Skip to main content

Backup and Restore

Purpose

This page documents the backup and restore approach for Maqsafy services, including database backups, file backups, restore validation, retention, and security rules.

Backup Scope

ComponentBackup RequiredNotes
MySQL DatabaseYesCore operational and financial data
Uploaded FilesYesAttachments, invoices, reports, media
Environment ConfigurationYesStore securely, do not place secrets in documentation
Application CodeYesManaged through version control or release artifacts
Nginx ConfigurationYesRequired for recovery
Docker Compose FilesYes, if usedRequired to rebuild services
SSL CertificatesYesStore securely with restricted access
LogsOptional / Policy-basedUseful for audit and incident investigation

Backup Types

TypeDescription
Full BackupComplete backup of the database or file set
Incremental BackupBackup of changes since the last backup
Logical Database BackupSQL dump that can recreate schema and data
File BackupBackup of uploaded files, invoices, exports, and media
Configuration BackupBackup of service configuration files

Database Backup

MySQL provides mysqldump as a logical backup utility that can produce SQL statements to recreate database objects and table data.

Example placeholder:

mysqldump --single-transaction --routines --triggers \
-h <db-host> -u <db-user> -p <database-name> > backup.sql

Compressed example:

mysqldump --single-transaction --routines --triggers \
-h <db-host> -u <db-user> -p <database-name> | gzip > backup.sql.gz

File Backup

Document the actual file paths used in production.

Example placeholders:

tar -czf uploads-backup.tar.gz /path/to/storage/app/public
tar -czf nginx-config-backup.tar.gz /etc/nginx/sites-available

Backup Schedule

Backup ItemFrequencyRetentionStorage LocationStatus
MySQL DatabaseDailyLifetime / indefinite retentionS3Confirmed
Uploaded FilesTo be confirmedLifetime / indefinite retention if includedS3Needs Technical Verification
Configuration FilesTo be confirmedLifetime / indefinite retention if includedS3Needs Technical Verification

Restore Procedure

A backup is only useful if restoration is tested.

General restore flow:

  1. Identify the required restore point.
  2. Confirm the affected environment.
  3. Stop affected services if required.
  4. Restore database backup.
  5. Restore uploaded files if required.
  6. Restore configuration files if required.
  7. Clear application cache.
  8. Restart services.
  9. Validate application functionality.
  10. Document the restore result.

Database Restore Example

Use placeholders only.

gunzip backup.sql.gz
mysql -h <db-host> -u <db-user> -p <database-name> < backup.sql

If the backup is not compressed:

mysql -h <db-host> -u <db-user> -p <database-name> < backup.sql

Laravel Post-Restore Commands

After restore, validate configuration and clear cache if needed.

php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan queue:restart

Restore Validation Checklist

CheckExpected Result
Application loadsHomepage or health endpoint responds
Login worksAuthorized users can log in
Database connection worksDashboard data loads
Files are accessibleUploaded files and attachments load
Queue workers workBackground jobs process correctly
Reports workKey reports generate correctly
Logs are cleanNo new critical errors

RPO and RTO

TermMeaningMaqsafy TargetStatus
RPOMaximum acceptable data loss windowZero data loss targetNeeds technical wording validation
RTOMaximum acceptable time to restore serviceLess than 1 hourConfirmed

Restore Test Status

ItemStatusNotes
Restore test performedConfirmedTechnical team confirmed restore testing exists
Restore evidence availableNeeds EvidenceAdd date, environment, and validation result
Last restore test dateNeeds EvidenceAdd when confirmed

Backup Security

  • Backup files must not be publicly accessible.
  • Backup files should be encrypted where applicable.
  • Access to backups must be restricted to authorized personnel only.
  • Backup storage credentials must not be documented.
  • Backup download links must not be public.
  • Backup restore actions must be logged.

Backup Testing

Test restore procedures periodically.

TestFrequencyNotes
Database restore testTBDRestore to non-production environment
File restore testTBDValidate uploaded files and attachments
Full environment recovery testTBDValidate application, database, files, and services

Incident Restore Log

Use this format when a restore operation is performed.

## YYYY-MM-DD - Restore Operation

| Field | Details |
|---|---|
| Environment | Production / Staging / Local |
| Restore Point | Backup timestamp |
| Reason | Incident or maintenance reason |
| Database Restored | Yes / No |
| Files Restored | Yes / No |
| Configuration Restored | Yes / No |
| RPO Impact | Actual data loss window |
| RTO Impact | Actual restore duration |
| Validation Result | Passed / Failed |
| Owner | Responsible person/team |

Rules

  • Do not overwrite production data without approval.
  • Do not run restore commands before confirming the target environment.
  • Do not expose backup files publicly.
  • Do not document real backup passwords or storage keys.
  • Do not store backup archives inside public web directories.