How maximeperrindev/archive-manager works
Project Overview & Purpose
• Archive Manager is a Python-based utility designed to automatically manage the archiving process. It takes a compressed folder containing a SQL dump, downloads it from a specified URL, extracts the SQL file, and then uploads it to a remote WebDAV server.
• It also handles logging, notifications (via Mattermost and email), and supports execution via manual command line or scheduled Cron jobs.
Main Components
• Command Line / Cron Trigger: This represents the user or scheduler that runs the archive.py script.
• Main Application (archive.py): The central component that orchestrates the process.
• Configuration Module: Uses the conf.ini file (provided as conf_example.ini) to specify parameters like file URLs, server credentials, conservation time, and notification settings.
• File Downloader: Handles the retrieval of the compressed folder from a designated URL.
• Extraction Module: Unzips the downloaded file and extracts the SQL file.
• Logging System: Generates the archive.log file where all operational logs and error messages are recorded.
• Remote Server Client: Connects to the WebDAV server to upload the prepared archive.
• Notification System: Optionally sends notifications using Mail and Mattermost (if enabled in the configuration).
• Resources Folder: The directory that gets created by the script (stores the downloaded zip and extracted SQL file).
System Interactions & Data Flow
• The process starts when the script is invoked (either by a user manually or via a Cron job).
• The script reads the configuration from conf.ini to fetch settings (URLs, file names, server credentials, notification preferences).
• Using these settings, the File Downloader component downloads the compressed file.
• The Extraction Module processes the downloaded archive to extract the SQL file.
• Throughout these steps, each action (including errors) is logged by the Logging System.
• Next, the Remote Server Client connects (using provided credentials) to the WebDAV server to upload the processed archive.
• Upon completion of the above steps, the Notification System sends alerts (via email or Mattermost) to indicate the success or failure of each step.
• Finally, the system may also call a clean-up or verification module (if needed) to check for expired files based on the conservation time setting.
Architectural Patterns & Design Principles
• Modular Design: Although it’s a single script, the functionality is conceptually partitioned into discrete responsibilities (configuration, downloading, extraction, logging, uploading, notification).
• Separation of Concerns: Each functional component (e.g., file download vs. upload) is distinct, making it easier to maintain or extend.
• Automation & Scheduling: The design supports both manual execution and periodic execution through Cron.
• Fault Tolerance via Logging: Detailed logs ensure that error diagnosis is straightforward.