Skip to content

Backup and Restore

This guide covers database and file backup procedures, automated backup setup, and restore processes to protect your OmniSuite CMS installation.


Table of Contents

  1. Overview
  2. Database Backup
  3. File Backup
  4. Automated Backups
  5. Restore Procedures
  6. Backup Best Practices

Overview

Why Backup?

  • ✅ Protect against data loss
  • ✅ Recover from errors
  • ✅ Restore after updates
  • ✅ Disaster recovery
  • ✅ Migration support

What to Backup

Critical Data:

  • Database (all tables)
  • Uploaded files
  • Configuration files
  • Custom code
  • Environment files

Database Backup

Manual Backup Methods

Method 1: cPanel phpMyAdmin

  1. Access phpMyAdmin:

    • Log in to cPanel
    • Click phpMyAdmin
  2. Select Database:

    • Choose your database
    • Click database name
  3. Export:

    • Click Export tab
    • Select Quick or Custom
    • Choose format: SQL
    • Click Go
  4. Download:

    • File downloads
    • Save securely
    • Name with date

Method 2: Command Line (MySQL)

Using mysqldump:

bash
mysqldump -u username -p database_name > backup_$(date +%Y%m%d).sql

With Compression:

bash
mysqldump -u username -p database_name | gzip > backup_$(date +%Y%m%d).sql.gz

Method 3: Laravel Artisan

Backup Command:

bash
php artisan db:backup

Or use package:

bash
php artisan backup:run

Automated Database Backup

Cron Job Setup

Create Backup Script:

bash
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
mysqldump -u username -p'password' database_name > /backups/db_$DATE.sql
gzip /backups/db_$DATE.sql
find /backups -name "db_*.sql.gz" -mtime +7 -delete

Add to Crontab:

bash
0 2 * * * /path/to/backup-script.sh

File Backup

What Files to Backup

Critical Files

Configuration:

  • .env file
  • config/ directory
  • Custom configurations

Uploaded Content:

  • storage/app/public/
  • Media files
  • User uploads

Custom Code:

  • Custom modules
  • Modified templates
  • Custom components

Manual File Backup

Method 1: FTP/SFTP

  1. Connect via FTP:

    • Use FTP client
    • Connect to server
  2. Download Files:

    • Download entire directory
    • Or selective files
    • Save locally

Method 2: Command Line (SCP)

Copy Files:

bash
scp -r user@server:/path/to/files /local/backup/

With Compression:

bash
tar -czf backup.tar.gz /path/to/files
scp backup.tar.gz user@server:/backup/

Method 3: cPanel File Manager

  1. Access File Manager:

    • Log in to cPanel
    • Click File Manager
  2. Select Files:

    • Navigate to directory
    • Select files/folders
  3. Compress:

    • Right-click → Compress
    • Choose format (ZIP)
    • Download archive

Automated File Backup

Backup Script

Create Script:

bash
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
tar -czf /backups/files_$DATE.tar.gz \
  /path/to/storage \
  /path/to/config \
  /path/to/.env
find /backups -name "files_*.tar.gz" -mtime +7 -delete

Add to Crontab:

bash
0 3 * * * /path/to/file-backup-script.sh

Automated Backups

Backup Solutions

Option 1: Laravel Backup Package

Install:

bash
composer require spatie/laravel-backup

Configure:

php
// config/backup.php
'backup' => [
    'destination' => [
        'disks' => ['local', 's3'],
    ],
],

Schedule:

php
// app/Console/Kernel.php
$schedule->command('backup:run')->daily();

Option 2: Server-Level Backup

cPanel Backup:

  • Enable automatic backups
  • Configure in cPanel
  • Set retention period

VPS Backup:

  • Use backup service
  • Configure automated backups
  • Set schedule

Backup Schedule

Daily Backups:

  • Database: Daily
  • Files: Daily
  • Full: Weekly

Retention:

  • Daily: 7 days
  • Weekly: 4 weeks
  • Monthly: 12 months

Restore Procedures

Database Restore

Method 1: phpMyAdmin

  1. Access phpMyAdmin:

    • Log in to cPanel
    • Click phpMyAdmin
  2. Select Database:

    • Choose database
    • Click database name
  3. Import:

    • Click Import tab
    • Choose file
    • Click Go
  4. Verify:

    • Check tables
    • Verify data
    • Test application

Method 2: Command Line

Restore:

bash
mysql -u username -p database_name < backup.sql

From Compressed:

bash
gunzip < backup.sql.gz | mysql -u username -p database_name

Method 3: Laravel Artisan

Restore:

bash
php artisan db:restore backup.sql

File Restore

Method 1: FTP/SFTP

  1. Connect:

    • Use FTP client
    • Connect to server
  2. Upload Files:

    • Upload backup files
    • Overwrite existing
    • Set permissions

Method 2: Command Line

Extract Archive:

bash
tar -xzf backup.tar.gz -C /restore/path/

Copy Files:

bash
cp -r /backup/files/* /path/to/application/

Full Restore Process

Step-by-Step

  1. Stop Application:

    • Put in maintenance mode
    • Stop services if needed
  2. Restore Database:

    • Import database backup
    • Verify import
  3. Restore Files:

    • Restore file backup
    • Set permissions
  4. Update Configuration:

    • Update .env if needed
    • Clear cache
  5. Verify:

    • Test application
    • Check functionality
    • Remove maintenance mode

Backup Best Practices

Backup Strategy

  1. Regular Backups:

    • Daily automated backups
    • Before major changes
    • Before updates
  2. Multiple Locations:

    • Local storage
    • Remote storage
    • Cloud storage
  3. Test Restores:

    • Test restore process
    • Verify backups work
    • Document procedures

Storage

  1. Secure Storage:

    • Encrypt backups
    • Secure access
    • Off-site storage
  2. Organize Backups:

    • Name with dates
    • Organize by type
    • Keep logs
  3. Retention Policy:

    • Define retention
    • Automate cleanup
    • Archive important

Monitoring

  1. Monitor Backups:

    • Check backup logs
    • Verify success
    • Alert on failure
  2. Regular Review:

    • Review backup logs
    • Check storage space
    • Update procedures

Troubleshooting

Backup Fails

Solutions:

  1. Check disk space
  2. Verify permissions
  3. Check database access
  4. Review error logs
  5. Test manually

Restore Fails

Solutions:

  1. Verify backup file
  2. Check file integrity
  3. Verify database access
  4. Check permissions
  5. Review error messages


Last Updated: [Date will be updated during final review]

Released under the MIT License.