Skip to main content

A command-line tool for backing up, restoring, and generating reports from Olog servers

Project description

Olog Tool

A command-line tool for backing up, restoring, and generating reports from Olog servers using the Olog REST API.

Features

  • Backup: Complete backup of logs and attachments from an Olog server
  • Restore: Restore logs and attachments from a backup
  • Markdown Reports: Generate Markdown documentation of logs with custom titles
  • PDF Reports: Generate PDF reports with logs, metadata, and embedded images with custom titles
  • HTML Reports: Generate HTML reports with logs, metadata, and embedded images with custom titles

Installation

From PyPI (Recommended)

pip install olog-tool

From Source

  1. Clone or download this repository
  2. Install dependencies:
pip install -r requirements.txt

Or install in development mode:

pip install -e .

Usage

Basic Syntax

olog-tool --url <olog-server-url> [OPTIONS] COMMAND

Authentication

Use the --username and --password options for authenticated access:

olog-tool --url https://olog.example.com --username myuser --password mypass COMMAND

Time Range

Use --start and --end to specify a time range (ISO format):

olog-tool --url https://olog.example.com --start 2025-01-01T00:00:00 --end 2025-12-31T23:59:59 COMMAND

Commands

Backup

Backup all logs and attachments from the Olog server:

olog-tool --url https://olog.example.com --username user --password pass backup --output ./backup_dir

With time range:

olog-tool --url https://olog.example.com \
  --start 2025-01-01T00:00:00 \
  --end 2025-01-31T23:59:59 \
  backup --output ./backup_january

Restore

Restore logs and attachments from a backup directory:

olog-tool --url https://olog.example.com --username user --password pass restore --input ./backup_dir

Note: The restore operation creates new log entries, so the log IDs in the restored server will be different from the original.

Generate Markdown Report

Create a Markdown document with logs and their metadata:

olog-tool --url https://olog.example.com markdown --output report.md

With time range and authentication:

olog-tool --url https://olog.example.com \
  --username user --password pass \
  --start 2025-01-01T00:00:00 \
  --end 2025-01-31T23:59:59 \
  markdown --output january_report.md

Generate PDF Report

Create a PDF document with logs and their metadata. Image attachments are automatically embedded in the PDF:

olog-tool --url https://olog.example.com pdf --output report.pdf

With time range and authentication:

olog-tool --url https://olog.example.com \
  --username user --password pass \
  --start 2025-01-01T00:00:00 \
  --end 2025-01-31T23:59:59 \
  pdf --output january_report.pdf

To disable embedding of image attachments (faster, smaller file):

olog-tool --url https://olog.example.com pdf --output report.pdf --no-embed

Generate HTML Report

Create an HTML document with logs and their metadata. Image attachments are automatically embedded as base64:

olog-tool --url https://olog.example.com html --output report.html

With time range and authentication:

olog-tool --url https://olog.example.com \
  --username user --password pass \
  --start 2025-01-01T00:00:00 \
  --end 2025-01-31T23:59:59 \
  html --output january_report.html

To disable embedding of image attachments:

olog-tool --url https://olog.example.com html --output report.html --no-embed

Examples

Example 1: Monthly Backup

Backup all logs from October 2025:

olog-tool \
  --url https://olog.example.com \
  --username admin \
  --password secret \
  --start 2025-10-01T00:00:00 \
  --end 2025-10-31T23:59:59 \
  backup --output ./backup_2025_10

Example 2: Generate Reports with Custom Titles

Generate Markdown, HTML, and PDF reports for a specific time range with custom titles:

# Markdown report with custom title
olog-tool \
  --url https://olog.example.com \
  --start 2025-11-01T00:00:00 \
  --end 2025-11-07T23:59:59 \
  --title "Weekly Operations Summary" \
  markdown --output weekly_report.md

# HTML report with embedded images and custom title
olog-tool \
  --url https://olog.example.com \
  --start 2025-11-01T00:00:00 \
  --end 2025-11-07T23:59:59 \
  --title "Beamline Status Report" \
  html --output weekly_report.html

# PDF report with embedded images and custom title
olog-tool \
  --url https://olog.example.com \
  --start 2025-11-01T00:00:00 \
  --end 2025-11-07T23:59:59 \
  --title "Weekly Operations Report" \
  pdf --output weekly_report.pdf

Example 3: Complete Backup and Restore

Backup from one server and restore to another:

# Backup from production
olog-tool \
  --url https://olog-prod.example.com \
  --username admin \
  --password prod_pass \
  backup --output ./prod_backup

# Restore to development
olog-tool \
  --url https://olog-dev.example.com \
  --username admin \
  --password dev_pass \
  restore --input ./prod_backup

Backup Directory Structure

When you create a backup, the following structure is created:

backup_dir/
├── logs.json              # JSON file with all log metadata
└── attachments/           # Directory containing attachments
    ├── 123/               # Directory for log ID 123
    │   ├── image1.png
    │   └── data.csv
    └── 124/               # Directory for log ID 124
        └── document.pdf

Requirements

  • Python 3.6 or higher
  • requests library
  • reportlab library (for PDF generation)

API Reference

This tool uses the Olog REST API. The main endpoints used are:

  • GET /logs - Search for logs
  • GET /logs/{id} - Get a specific log
  • GET /logs/attachments/{id}/{filename} - Download attachment
  • PUT /logs - Create a new log
  • POST /logs/attachments/{id} - Upload attachment

Limitations

  • The backup/restore process creates new log entries, so log IDs will be different
  • Very large backups may take significant time and disk space
  • PDF generation requires the reportlab library
  • Image embedding in PDF/HTML works for common formats (PNG, JPG, GIF, BMP, SVG)
  • Large images are automatically scaled in PDF to fit the page
  • HTML reports with many embedded images may be large files

License

This tool is provided as-is for use with Olog servers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

olog_tool-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

olog_tool-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file olog_tool-0.1.0.tar.gz.

File metadata

  • Download URL: olog_tool-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for olog_tool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a9bad2f88baefd53e9ddfc98207486ce0721557fc5a0b94eccd265b60df2d8e
MD5 a2af752e2f75e98782591af7634d5119
BLAKE2b-256 8cf80f345d4238cfb7e8ac99dfc294d6a0d2f5bbef64d04989a5841d2ffbface

See more details on using hashes here.

File details

Details for the file olog_tool-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: olog_tool-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for olog_tool-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1afcd0f99677a7fe098559c029bd7334a7a3d9336dea1942551a004023e154de
MD5 406ed6524df05c5c12cd44adbae6168f
BLAKE2b-256 e273ed87e6f4abe43e2e182379f3e362820f6b8b85b46726569854a3f9c071ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page