6.8 KiB
MB Backup Manager Documentation
Overview
The MB Backup Manager is a comprehensive backup solution designed for managing automated backups of web applications, particularly those running on the Virtuozzo Application Platform. This tool leverages Restic for efficient backup storage and management, with support for automated scheduling through cron jobs.
Features
- Automated Backups: Schedule and manage backups using
manage_backup_schedule.sh
- Backup Types:
- Core files backup (
backup_core_files.sh
) - Media files backup (
backup_media.sh
) - Database backup (
backup_database.sh
)
- Core files backup (
- Backup Management:
- View snapshots with tag filtering (
view_snapshots.sh
) - Direct backup restoration (
restore_backup_direct.sh
) - Repository statistics and maintenance (
check_repo_stats.sh
) - Repository validation (
check_backup_repo.sh
)
- View snapshots with tag filtering (
- Logging: Comprehensive logging system with separate directories for automated and manual backups
- Backup Orchestration: Centralized backup management through
backup_all.sh
Installation
-
Clone the Repository: Clone the repository containing the backup manager scripts to your local machine or server. MB Backup Manager Repository
-
Install Dependencies: Ensure that
Restic
andcron
are installed on your system:sudo dnf install -y cronie sudo dnf install -y restic
-
Set Up Directory Structure: Create the necessary directories for logs:
mkdir -p /home/litespeed/mb-backups/logs/auto mkdir -p /home/litespeed/mb-backups/logs/manual
-
Configure Environment: Ensure the Restic password is stored in
/etc/restic-password
.
Core Scripts and Usage
Backup Management
-
Viewing Snapshots (
view_snapshots.sh
):- View all snapshots or filter by specific tags
- Displays snapshot IDs, timestamps, and associated tags
- Supports an
all
tag to show all snapshots regardless of tags
-
Direct Backup Restoration (
restore_backup_direct.sh
):- Restores specific backup types based on tags
- Handles direct database restoration by piping SQL files from Restic to MySQL
- Automatically detects database credentials from
wp-config.php
-
Backup Scheduling (
manage_backup_schedule.sh
):- Add or update backup schedules with cron
- Remove existing backup schedules
- Validates cron syntax and dependencies
- Logs all scheduling actions
-
Repository Maintenance (
check_repo_stats.sh
):- Retrieves detailed repository statistics.
- Applies retention policies to manage snapshot storage:
- Default Retention: Keeps only the last 7 snapshots to balance storage usage and recovery needs.
- Forgotten snapshots are pruned to reclaim storage space.
- Performs repository integrity checks to ensure data consistency and reliability.
- Automatically detects and removes stale locks to prevent repository conflicts.
- Logs all actions and results to
repo_stats_YYYY-MM-DD.log
for traceability.
-
Repository Validation (
check_backup_repo.sh
):- Validates repository integrity
- Initializes empty repositories
- Handles stale locks
- Logs to
/home/litespeed/logs/backup_repo_check.log
Backup Components
-
Complete Backup (
backup_all.sh
):- Orchestrates the entire backup process
- Calls individual backup scripts for core, media, and database
- Applies consistent tagging (
manual-backup
orauto-backup
with timestamps) - Handles error logging and reporting
-
Individual Backup Scripts:
backup_core_files.sh
: Backs up essential application filesbackup_media.sh
: Handles media file backupsbackup_database.sh
: Manages database backups- Each script can run independently or as part of
backup_all.sh
Schedule Monitoring
Check Scheduled Backups (check_sched.sh
):
./check_sched.sh
Displays current backup-related cron jobs and automation status.
Available Commands
Backup Management Commands
-
Schedule Management (
manage_backup_schedule.sh
):# Add or update a backup schedule ./manage_backup_schedule.sh add "0 0 * * *" "your_restic_password" # Remove all backup schedules ./manage_backup_schedule.sh remove # List current backup schedules ./manage_backup_schedule.sh list
-
Manual Backup Operations (
backup_all.sh
):# Run a manual backup ./backup_all.sh manual # Run an automated backup (used by cron) ./backup_all.sh auto
-
Individual Backup Components:
# Core files backup ./backup_core_files.sh "restic_password" "backup_tag" # Database backup ./backup_database.sh "restic_password" "backup_tag" # Media files backup ./backup_media.sh "restic_password" "backup_tag"
-
Repository Management:
# Check repository status ./check_repo_stats.sh # Validate repository ./check_backup_repo.sh # View snapshots (all or by tag) ./view_snapshots.sh
-
Schedule Monitoring:
# Check current backup schedules ./check_sched.sh
-
Backup Restoration:
# Restore backups directly ./restore_backup_direct.sh
Environment Variables
The following environment variables are used by the scripts:
RESTIC_PASSWORD
: Stored in/etc/restic-password
RESTIC_REPOSITORY
: Default path/mnt/backup
Log File Locations
- Automated backup logs:
/home/litespeed/mb-backups/logs/auto/
- Manual backup logs:
/home/litespeed/mb-backups/logs/manual/
- Repository stats:
repo_stats_YYYY-MM-DD.log
- Repository check logs:
/home/litespeed/logs/backup_repo_check.log
- Schedule actions log:
/home/litespeed/mb-backups/logs/auto/schedule_actions.log
- Backup addon log:
/var/log/backup_addon.log
Troubleshooting
-
Cron Service Issues:
sudo systemctl status crond sudo systemctl start crond sudo systemctl enable crond
-
Log Locations:
- Automated backup logs:
/home/litespeed/mb-backups/logs/auto/
- Manual backup logs:
/home/litespeed/mb-backups/logs/manual/
- Repository stats:
repo_stats_YYYY-MM-DD.log
- Repository check logs:
/home/litespeed/logs/backup_repo_check.log
- Automated backup logs:
-
Common Issues:
- Stale locks: Automatically handled by scripts
- Repository access: Verify Restic password in
/etc/restic-password
- Backup failures: Check corresponding log files for error messages
- Cron job issues: Verify cron service status and job configuration
-
Permissions:
chmod +x /home/litespeed/mb-backups/scripts/imports/*.sh
Repository Information
For the latest updates and commit history: MB Backup Manager Repository