# Backup & Restore System

## Features

### ✅ Database Backup
- Creates complete SQL dumps of all tables
- Includes table structure and data
- Automatic file naming with timestamps
- File size reporting
- Protected backup directory

### ✅ Database Restore
- Restores from SQL backup files
- Handles foreign key constraints
- Proper SQL parsing and execution
- Transaction safety
- Detailed error reporting

### ✅ Backup Management
- List all available backups
- Download backup files
- Delete old backups
- File size and date information

## Security Features

- Admin-only access (Superadmin required)
- Protected backup directory (.htaccess)
- File validation (only .sql files)
- Directory traversal protection
- Activity logging

## Usage

1. **Create Backup**: Click "Create Backup" button
2. **Restore**: Click restore button and confirm (⚠️ WARNING: Overwrites all data)
3. **Download**: Click download button to save backup locally
4. **Delete**: Remove old backups to save space

## File Location

Backups are stored in: `/backups/backup_YYYY-MM-DD_HH-MM-SS_XXXXXX.sql`

## Important Notes

- ⚠️ **ALWAYS create a backup before restoring**
- Restore operations cannot be undone
- Large databases may take time to backup/restore
- Ensure sufficient disk space for backups