MightyBox main backups manager
 
 
Go to file
Anthony c41466de6e Updated to version 1.3: Switched Restic installation to use precompiled binary for reduced memory usage. Added logic to create Restic password file if missing. Updated manifest.jps for versioning and log rotation setup. 2025-01-04 00:56:17 +08:00
scripts Updated manage_backup_schedule.sh to include cron installation and status checks, improved error handling, and enhanced logging for backup schedule management. 2025-01-04 00:14:30 +08:00
changelogs.md Updated to version 1.3: Switched Restic installation to use precompiled binary for reduced memory usage. Added logic to create Restic password file if missing. Updated manifest.jps for versioning and log rotation setup. 2025-01-04 00:56:17 +08:00
manifest.jps Updated to version 1.3: Switched Restic installation to use precompiled binary for reduced memory usage. Added logic to create Restic password file if missing. Updated manifest.jps for versioning and log rotation setup. 2025-01-04 00:56:17 +08:00
readme.md Enhanced logging in backup-logic.sh for better debugging, updated documentation in readme.md, and ensured log rotation in manifest.jps. 2025-01-04 00:39:04 +08:00

readme.md

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 cron jobs for scheduling backups and utilizes Restic for efficient backup storage and management.

Features

  • Automated Backups: Schedule daily, weekly, or custom backups using cron jobs.
  • Backup Types: Supports backing up core files, media files, and databases.
  • Logging: Detailed logging of backup operations for monitoring and troubleshooting.
  • Backup Rotation: Automatically manages old backups to save storage space.

Installation

  1. Clone the Repository: Clone the repository containing the backup manager scripts to your local machine or server. The repository can be found at: MB Backup Manager Repository

  2. Install Dependencies: Ensure that Restic and cron are installed on your system. You can install them using the following commands:

    sudo dnf install -y cronie
    sudo dnf install -y restic
    
  3. Set Up Directory Structure: Create the necessary directories for logs and scripts:

    mkdir -p /home/litespeed/mb-backups/logs/auto
    mkdir -p /home/litespeed/mb-backups/logs/manual
    
  4. Configure Environment: Ensure that the environment variables and configuration files are set up correctly, including the Restic password stored in /etc/restic-password.

  5. Install from the Virtuozzo Marketplace: To install the MB Backup Manager from the Virtuozzo Marketplace, follow these steps:

    • Log in to your Virtuozzo Application Platform dashboard.
    • Navigate to the Marketplace section.
    • Search for "MB Backup Manager" in the marketplace.
    • Click on the application to view its details and click the Install button.
    • Follow the prompts to complete the installation process.

    For more detailed instructions on using the Virtuozzo Marketplace, refer to the official documentation: Virtuozzo Marketplace Documentation.

Usage

Managing Backup Schedules

The manage_backup_schedule.sh script is used to add, update, or remove backup schedules.

  • Add or Update a Backup Schedule:

    To add or update a backup schedule, run the following command:

    ./manage_backup_schedule.sh add '0 1 * * *' 'your_restic_password'
    

    This example schedules a backup to run daily at 1 AM.

  • Remove a Backup Schedule:

    To remove an existing backup schedule, use:

    ./manage_backup_schedule.sh remove
    

Checking Scheduled Backups

You can check the current scheduled backups using the check_sched.sh script:

./check_sched.sh

This will log the current cron jobs related to the backup script and indicate whether automated backups are enabled.

Running Backups Manually

To run backups manually, you can execute the backup_all.sh script directly:

bash /home/litespeed/mb-backups/backup_all.sh

Troubleshooting

  1. Cron Service Issues:

    • If the cron service is not running, ensure it is installed and started:
      sudo systemctl start crond
      sudo systemctl enable crond
      
    • To check the status of the cron service, you can run:
      systemctl status crond
      
    • If the service fails to start, check the system logs for any error messages related to cron:
      journalctl -xe | grep crond
      
  2. Log Files:

    • Check the log files located in /home/litespeed/mb-backups/logs/auto for any errors or issues during backup operations.
    • Each backup run generates a log file with a timestamp, which can help identify when issues occurred.
  3. Restic Issues:

    • Ensure that Restic is installed and configured correctly. You can verify its installation by running:
      restic version
      
    • If you encounter issues with Restic, check the Restic logs for detailed error messages. You can enable verbose logging by adding the -v flag to your Restic commands.
  4. Backup Failures:

    • If a backup fails, check the corresponding log file for detailed error messages. The logs are typically located in /var/log/backup_addon.log.
    • Look for specific error messages that indicate what went wrong during the backup process.
  5. Cron Job Not Found:

    • If the scheduled cron job is not found, ensure that the manage_backup_schedule.sh script was executed successfully and that the cron job was added correctly.
    • You can list the current cron jobs by running:
      crontab -l
      
    • If the job is missing, re-run the manage_backup_schedule.sh script with the correct parameters.
  6. Debugging Cron Jobs:

    • If your cron job is not executing as expected, you can redirect the output and error messages to a log file by modifying the cron command in the manage_backup_schedule.sh script. For example:
      CMD="RESTIC_PASSWORD=\"$3\" $BACKUP_SCRIPT > \"${BACKUP_LOG_PREFIX}\$(date +\\%Y-\\%m-\\%d_\\%H-\\%M-\\%S).log\" 2>&1"
      
    • This will help capture any errors that occur when the cron job runs.
  7. Environment Variables:

    • Ensure that any environment variables required by your scripts (like RESTIC_PASSWORD) are set correctly. You can check the environment variables in your cron jobs by adding a command to print them to a log file:
      env > /home/litespeed/mb-backups/logs/cron_env.log
      
  8. Permissions:

    • Ensure that the scripts have the correct permissions to execute. You can set the executable permission using:
      chmod +x /home/litespeed/mb-backups/*.sh
      
  9. Testing Scripts Manually:

    • If you suspect an issue with a specific script, try running it manually in the terminal to see if it executes without errors. This can help isolate the problem.
  10. Check for Running Processes:

    • If you suspect that a backup process is already running, you can check for running instances of your backup scripts using:
      pgrep -f backup_all.sh
      
    • This will show you if there are any active processes related to your backup operations.

By following these debugging tips, you can effectively troubleshoot issues related to the MB Backup Manager and ensure that your backup processes run smoothly.

Conclusion

The MB Backup Manager provides a robust solution for managing backups in a cloud environment. By following the guidelines outlined in this documentation, developers can effectively set up, manage, and troubleshoot the backup processes. For further assistance, please refer to the log files or reach out to the development team.

Repository Information

For the latest updates and commit history, you can find the repository at: MB Backup Manager Repository