Add full restore button
parent
b61d38b946
commit
d95792d5a3
40
manifest.jps
40
manifest.jps
|
@ -35,6 +35,13 @@ settings:
|
||||||
- name: snapshotId
|
- name: snapshotId
|
||||||
caption: Snapshot ID
|
caption: Snapshot ID
|
||||||
type: string
|
type: string
|
||||||
|
fullRestoreSettings:
|
||||||
|
submitUnchanged: true
|
||||||
|
fields:
|
||||||
|
- name: backupSessionTag
|
||||||
|
caption: Backup Session Tag
|
||||||
|
type: string
|
||||||
|
placeholder: "e.g., manual-backup-2024-01-15_10-30-45"
|
||||||
|
|
||||||
buttons:
|
buttons:
|
||||||
- caption: Backup Now
|
- caption: Backup Now
|
||||||
|
@ -113,6 +120,21 @@ menu:
|
||||||
title: Restore from Snapshot
|
title: Restore from Snapshot
|
||||||
submitButtonText: Restore Now
|
submitButtonText: Restore Now
|
||||||
|
|
||||||
|
- caption: View Backup Sessions
|
||||||
|
action: viewBackupSessions
|
||||||
|
confirmText: View available backup sessions?
|
||||||
|
loadingText: Retrieving backup sessions...
|
||||||
|
successText: Backup sessions listed successfully.
|
||||||
|
|
||||||
|
- caption: Full Backup Session Restore
|
||||||
|
confirmText: Restore complete backup session? This will restore database, core files, and media files from the same backup session.
|
||||||
|
loadingText: Restoring full backup session...
|
||||||
|
action: restoreFullBackupSession
|
||||||
|
successText: Full backup session restoration completed successfully
|
||||||
|
settings: fullRestoreSettings
|
||||||
|
title: Full Backup Session Restore
|
||||||
|
submitButtonText: Restore Full Session
|
||||||
|
|
||||||
- caption: View All Backups
|
- caption: View All Backups
|
||||||
action: viewAllBackups
|
action: viewAllBackups
|
||||||
confirmText: Are you sure you want to view all backups?
|
confirmText: Are you sure you want to view all backups?
|
||||||
|
@ -230,6 +252,22 @@ actions:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
|
|
||||||
|
viewBackupSessions:
|
||||||
|
- cmd[cp]:
|
||||||
|
user: root
|
||||||
|
commands: bash /home/litespeed/mb-backups/view_backup_sessions.sh sessions
|
||||||
|
- return:
|
||||||
|
type: info
|
||||||
|
message: "${response.out}"
|
||||||
|
|
||||||
|
restoreFullBackupSession:
|
||||||
|
- cmd[cp]:
|
||||||
|
user: root
|
||||||
|
commands: bash /home/litespeed/mb-backups/restore_full_backup_session.sh "${settings.backupSessionTag}"
|
||||||
|
- return:
|
||||||
|
type: info
|
||||||
|
message: "${response.out}"
|
||||||
|
|
||||||
viewAllBackups:
|
viewAllBackups:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
user: root
|
user: root
|
||||||
|
@ -328,7 +366,9 @@ actions:
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_sched.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_sched.sh
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/manage_backup_schedule.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/manage_backup_schedule.sh
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/restore_backup_direct.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/restore_backup_direct.sh
|
||||||
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/restore_full_backup_session.sh
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/view_snapshots.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/view_snapshots.sh
|
||||||
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/view_backup_sessions.sh
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_backup_repo.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_backup_repo.sh
|
||||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_repo_stats.sh
|
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_repo_stats.sh
|
||||||
- chmod +x /home/litespeed/mb-backups/*.sh
|
- chmod +x /home/litespeed/mb-backups/*.sh
|
||||||
|
|
141
readme.md
141
readme.md
|
@ -11,14 +11,93 @@ The **MB Backup Manager** is a comprehensive backup solution designed for managi
|
||||||
- Core files backup (`backup_core_files.sh`)
|
- Core files backup (`backup_core_files.sh`)
|
||||||
- Media files backup (`backup_media.sh`)
|
- Media files backup (`backup_media.sh`)
|
||||||
- Database backup (`backup_database.sh`)
|
- Database backup (`backup_database.sh`)
|
||||||
|
- **Full Backup Sessions**: Complete backup orchestration with session-based restoration
|
||||||
- **Backup Management**:
|
- **Backup Management**:
|
||||||
- View snapshots with tag filtering (`view_snapshots.sh`)
|
- View snapshots with tag filtering (`view_snapshots.sh`)
|
||||||
|
- View backup sessions as logical units (`view_backup_sessions.sh`)
|
||||||
- Direct backup restoration (`restore_backup_direct.sh`)
|
- Direct backup restoration (`restore_backup_direct.sh`)
|
||||||
|
- **Full backup session restoration** (`restore_full_backup_session.sh`)
|
||||||
- Repository statistics and maintenance (`check_repo_stats.sh`)
|
- Repository statistics and maintenance (`check_repo_stats.sh`)
|
||||||
- Repository validation (`check_backup_repo.sh`)
|
- Repository validation (`check_backup_repo.sh`)
|
||||||
- **Logging**: Comprehensive logging system with separate directories for automated and manual backups
|
- **Logging**: Comprehensive logging system with separate directories for automated and manual backups
|
||||||
- **Backup Orchestration**: Centralized backup management through `backup_all.sh`
|
- **Backup Orchestration**: Centralized backup management through `backup_all.sh`
|
||||||
|
|
||||||
|
## New: Full Backup Session Restore
|
||||||
|
|
||||||
|
### Overview
|
||||||
|
The system now supports **hyper-accurate full backup session restoration** that ensures all components (database, core files, and media files) are restored from the same backup session, maintaining data consistency and integrity.
|
||||||
|
|
||||||
|
### Key Features
|
||||||
|
- **Session Validation**: Automatically validates that all required components are present
|
||||||
|
- **Timestamp Consistency**: Ensures all snapshots belong to the same backup session
|
||||||
|
- **Component Verification**: Confirms presence of core_files, media_themes, and wordpress_db tags
|
||||||
|
- **Pre-restoration Backup**: Creates a backup of current state before restoration
|
||||||
|
- **Comprehensive Logging**: Detailed logs for troubleshooting and audit trails
|
||||||
|
- **Error Recovery**: Graceful handling of failures with cleanup procedures
|
||||||
|
|
||||||
|
### How It Works
|
||||||
|
1. **Backup Session Creation**: When you run a full backup, three separate snapshots are created:
|
||||||
|
- Core files snapshot (tagged with `core_files`)
|
||||||
|
- Media files snapshot (tagged with `media_themes`)
|
||||||
|
- Database snapshot (tagged with `wordpress_db`)
|
||||||
|
- All snapshots share a common session tag (e.g., `manual-backup-2024-01-15_10-30-45`)
|
||||||
|
|
||||||
|
2. **Session Restoration**: The full restore process:
|
||||||
|
- Identifies all snapshots with the specified session tag
|
||||||
|
- Validates exactly 3 snapshots are present
|
||||||
|
- Confirms all required component tags are present
|
||||||
|
- Checks timestamp consistency (within 30 minutes)
|
||||||
|
- Creates pre-restoration backup
|
||||||
|
- Restores components in proper order (database → core files → media files)
|
||||||
|
- Verifies restoration integrity
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
#### Via Web Interface
|
||||||
|
1. **View Backup Sessions**: Use "View Backup Sessions" to see all complete backup sessions
|
||||||
|
2. **Full Restore**: Use "Full Backup Session Restore" and enter the session tag (e.g., `manual-backup-2024-01-15_10-30-45`)
|
||||||
|
|
||||||
|
#### Via Command Line
|
||||||
|
```bash
|
||||||
|
# View complete backup sessions
|
||||||
|
./view_backup_sessions.sh sessions
|
||||||
|
|
||||||
|
# View incomplete backup sessions
|
||||||
|
./view_backup_sessions.sh incomplete
|
||||||
|
|
||||||
|
# View all sessions with details
|
||||||
|
./view_backup_sessions.sh all
|
||||||
|
|
||||||
|
# Validate a specific backup session
|
||||||
|
./view_backup_sessions.sh validate manual-backup-2024-01-15_10-30-45
|
||||||
|
|
||||||
|
# Restore a complete backup session
|
||||||
|
./restore_full_backup_session.sh manual-backup-2024-01-15_10-30-45
|
||||||
|
```
|
||||||
|
|
||||||
|
### Safety Features
|
||||||
|
- **Format Validation**: Ensures session tag follows expected pattern
|
||||||
|
- **Component Count Validation**: Requires exactly 3 snapshots per session
|
||||||
|
- **Tag Validation**: Verifies all required component tags are present
|
||||||
|
- **Timestamp Validation**: Checks for reasonable time differences between snapshots
|
||||||
|
- **Pre-restoration Backup**: Creates backup of current state before restoration
|
||||||
|
- **Database Connectivity Test**: Validates database access before restoration
|
||||||
|
- **Comprehensive Error Handling**: Detailed error messages and cleanup procedures
|
||||||
|
|
||||||
|
### Example Output
|
||||||
|
```
|
||||||
|
=== COMPLETE BACKUP SESSIONS ===
|
||||||
|
Format: [Session Tag] [Date/Time] [Status]
|
||||||
|
========================================
|
||||||
|
manual-backup-2024-01-15_10-30-45 2024-01-15 10:30:45 [COMPLETE]
|
||||||
|
automated-backup-2024-01-15_02-00-30 2024-01-15 02:00:30 [COMPLETE]
|
||||||
|
========================================
|
||||||
|
Total complete backup sessions: 2
|
||||||
|
|
||||||
|
To restore a complete session, use:
|
||||||
|
./restore_full_backup_session.sh <session_tag>
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. **Clone the Repository**:
|
1. **Clone the Repository**:
|
||||||
|
@ -39,6 +118,7 @@ The **MB Backup Manager** is a comprehensive backup solution designed for managi
|
||||||
```bash
|
```bash
|
||||||
mkdir -p /home/litespeed/mb-backups/logs/auto
|
mkdir -p /home/litespeed/mb-backups/logs/auto
|
||||||
mkdir -p /home/litespeed/mb-backups/logs/manual
|
mkdir -p /home/litespeed/mb-backups/logs/manual
|
||||||
|
mkdir -p /home/litespeed/mb-backups/logs/restore
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Configure Environment**:
|
4. **Configure Environment**:
|
||||||
|
@ -53,18 +133,30 @@ The **MB Backup Manager** is a comprehensive backup solution designed for managi
|
||||||
- Displays snapshot IDs, timestamps, and associated tags
|
- Displays snapshot IDs, timestamps, and associated tags
|
||||||
- Supports an `all` tag to show all snapshots regardless of tags
|
- Supports an `all` tag to show all snapshots regardless of tags
|
||||||
|
|
||||||
2. **Direct Backup Restoration** (`restore_backup_direct.sh`):
|
2. **Viewing Backup Sessions** (`view_backup_sessions.sh`):
|
||||||
|
- View backup sessions as logical units
|
||||||
|
- Identify complete vs incomplete backup sessions
|
||||||
|
- Validate specific backup sessions before restoration
|
||||||
|
- Shows session timestamps and missing components
|
||||||
|
|
||||||
|
3. **Full Backup Session Restoration** (`restore_full_backup_session.sh`):
|
||||||
|
- Restores complete backup sessions with all components
|
||||||
|
- Validates session integrity before restoration
|
||||||
|
- Creates pre-restoration backup for safety
|
||||||
|
- Comprehensive error handling and logging
|
||||||
|
|
||||||
|
4. **Direct Backup Restoration** (`restore_backup_direct.sh`):
|
||||||
- Restores specific backup types based on tags
|
- Restores specific backup types based on tags
|
||||||
- Handles direct database restoration by piping SQL files from Restic to MySQL
|
- Handles direct database restoration by piping SQL files from Restic to MySQL
|
||||||
- Automatically detects database credentials from `wp-config.php`
|
- Automatically detects database credentials from `wp-config.php`
|
||||||
|
|
||||||
3. **Backup Scheduling** (`manage_backup_schedule.sh`):
|
5. **Backup Scheduling** (`manage_backup_schedule.sh`):
|
||||||
- Add or update backup schedules with cron
|
- Add or update backup schedules with cron
|
||||||
- Remove existing backup schedules
|
- Remove existing backup schedules
|
||||||
- Validates cron syntax and dependencies
|
- Validates cron syntax and dependencies
|
||||||
- Logs all scheduling actions
|
- Logs all scheduling actions
|
||||||
|
|
||||||
4. **Repository Maintenance** (`check_repo_stats.sh`):
|
6. **Repository Maintenance** (`check_repo_stats.sh`):
|
||||||
- Retrieves detailed repository statistics.
|
- Retrieves detailed repository statistics.
|
||||||
- Applies retention policies to manage snapshot storage:
|
- Applies retention policies to manage snapshot storage:
|
||||||
- **Default Retention**: Keeps only the last 7 snapshots to balance storage usage and recovery needs.
|
- **Default Retention**: Keeps only the last 7 snapshots to balance storage usage and recovery needs.
|
||||||
|
@ -73,7 +165,7 @@ The **MB Backup Manager** is a comprehensive backup solution designed for managi
|
||||||
- Automatically detects and removes stale locks to prevent repository conflicts.
|
- Automatically detects and removes stale locks to prevent repository conflicts.
|
||||||
- Logs all actions and results to `repo_stats_YYYY-MM-DD.log` for traceability.
|
- Logs all actions and results to `repo_stats_YYYY-MM-DD.log` for traceability.
|
||||||
|
|
||||||
5. **Repository Validation** (`check_backup_repo.sh`):
|
7. **Repository Validation** (`check_backup_repo.sh`):
|
||||||
- Validates repository integrity
|
- Validates repository integrity
|
||||||
- Initializes empty repositories
|
- Initializes empty repositories
|
||||||
- Handles stale locks
|
- Handles stale locks
|
||||||
|
@ -150,16 +242,37 @@ Displays current backup-related cron jobs and automation status.
|
||||||
./view_snapshots.sh
|
./view_snapshots.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
5. **Schedule Monitoring**:
|
5. **Backup Session Management**:
|
||||||
|
```bash
|
||||||
|
# View complete backup sessions
|
||||||
|
./view_backup_sessions.sh sessions
|
||||||
|
|
||||||
|
# View incomplete backup sessions
|
||||||
|
./view_backup_sessions.sh incomplete
|
||||||
|
|
||||||
|
# View all sessions with details
|
||||||
|
./view_backup_sessions.sh all
|
||||||
|
|
||||||
|
# Validate specific backup session
|
||||||
|
./view_backup_sessions.sh validate manual-backup-2024-01-15_10-30-45
|
||||||
|
|
||||||
|
# Restore complete backup session
|
||||||
|
./restore_full_backup_session.sh manual-backup-2024-01-15_10-30-45
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Schedule Monitoring**:
|
||||||
```bash
|
```bash
|
||||||
# Check current backup schedules
|
# Check current backup schedules
|
||||||
./check_sched.sh
|
./check_sched.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
6. **Backup Restoration**:
|
7. **Backup Restoration**:
|
||||||
```bash
|
```bash
|
||||||
# Restore backups directly
|
# Restore individual backup
|
||||||
./restore_backup_direct.sh
|
./restore_backup_direct.sh <snapshot_id>
|
||||||
|
|
||||||
|
# Restore complete backup session
|
||||||
|
./restore_full_backup_session.sh <session_tag>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
@ -173,6 +286,7 @@ The following environment variables are used by the scripts:
|
||||||
|
|
||||||
- Automated backup logs: `/home/litespeed/mb-backups/logs/auto/`
|
- Automated backup logs: `/home/litespeed/mb-backups/logs/auto/`
|
||||||
- Manual backup logs: `/home/litespeed/mb-backups/logs/manual/`
|
- Manual backup logs: `/home/litespeed/mb-backups/logs/manual/`
|
||||||
|
- Restoration logs: `/home/litespeed/mb-backups/logs/restore/`
|
||||||
- Repository stats: `repo_stats_YYYY-MM-DD.log`
|
- Repository stats: `repo_stats_YYYY-MM-DD.log`
|
||||||
- Repository check logs: `/home/litespeed/logs/backup_repo_check.log`
|
- Repository check logs: `/home/litespeed/logs/backup_repo_check.log`
|
||||||
- Schedule actions log: `/home/litespeed/mb-backups/logs/auto/schedule_actions.log`
|
- Schedule actions log: `/home/litespeed/mb-backups/logs/auto/schedule_actions.log`
|
||||||
|
@ -190,6 +304,7 @@ The following environment variables are used by the scripts:
|
||||||
2. **Log Locations**:
|
2. **Log Locations**:
|
||||||
- Automated backup logs: `/home/litespeed/mb-backups/logs/auto/`
|
- Automated backup logs: `/home/litespeed/mb-backups/logs/auto/`
|
||||||
- Manual backup logs: `/home/litespeed/mb-backups/logs/manual/`
|
- Manual backup logs: `/home/litespeed/mb-backups/logs/manual/`
|
||||||
|
- Restoration logs: `/home/litespeed/mb-backups/logs/restore/`
|
||||||
- Repository stats: `repo_stats_YYYY-MM-DD.log`
|
- Repository stats: `repo_stats_YYYY-MM-DD.log`
|
||||||
- Repository check logs: `/home/litespeed/logs/backup_repo_check.log`
|
- Repository check logs: `/home/litespeed/logs/backup_repo_check.log`
|
||||||
|
|
||||||
|
@ -198,11 +313,13 @@ The following environment variables are used by the scripts:
|
||||||
- Repository access: Verify Restic password in `/etc/restic-password`
|
- Repository access: Verify Restic password in `/etc/restic-password`
|
||||||
- Backup failures: Check corresponding log files for error messages
|
- Backup failures: Check corresponding log files for error messages
|
||||||
- Cron job issues: Verify cron service status and job configuration
|
- Cron job issues: Verify cron service status and job configuration
|
||||||
|
- Full restore failures: Check session completeness with `view_backup_sessions.sh validate`
|
||||||
|
|
||||||
4. **Permissions**:
|
4. **Full Restore Troubleshooting**:
|
||||||
```bash
|
- **Incomplete Session**: Use `view_backup_sessions.sh incomplete` to see missing components
|
||||||
chmod +x /home/litespeed/mb-backups/scripts/imports/*.sh
|
- **Invalid Session Tag**: Ensure tag format matches `manual-backup-YYYY-MM-DD_HH-MM-SS`
|
||||||
```
|
- **Timestamp Issues**: Check for large time differences between snapshots
|
||||||
|
- **Database Connection**: Verify MySQL service and credentials before restoration
|
||||||
|
|
||||||
## Repository Information
|
## Repository Information
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue