Skip to main content

Backup Reporter

This repository contains source code for backup reporter tool. That tool can collect backup information, upload it to S3 buckets or host, then collect bunch of backup information files, get them together into one csv file and upload it to google spreadsheet. Can save information to json and prom format.

Backup reporter has two working modes: reporter and collector.

Installation

To install backup-reporter to some machine (either in reporter or collector mode), ensure you have a python 3.8+ installed on that machine. If so, simply run pip3 install backup-reporter and wait to the end of setup process. After installation will be completed, run backup-reporter -h to get further steps help.

Installation as user

Beware that standard python packages installations which are ran by mean user, won't install console scripts to the PATH, so ensure to do so manually - or run installation as root.

Configuration

Reporter

Reporter can be configured with two ways: script arguments or configuration file. Possible configuration options you can find by typing backup-reporter -h. To use config file just pass --config your_config_file.yml as script argument. All options from cli-help are same for config-file. As example following command:

  • python3 main.py --destination="{'type': 's3'}" --bucket="{'s3_path': 's3://bucket_name/in_bucket_path/metadata_file_name.txt', 'aws_access_key_id': 'key', 'aws_secret_access_key': 'key', 'aws_region': 'region'}" --docker_postgres

can be written in file:

docker_postgres: true
bucket:
    - s3_path: s3://bucket_name/in_bucket_path/metadata_file_name.txt
      aws_access_key_id: key
      aws_secret_access_key: key
      aws_endpoint_url: url
      aws_region: region
      customer: "Customer name"

More examples can be found at docs/config-examples/reporter-*.conf

Collector

Collector can be configured the same way as reporter - with arguments passed to executable file or with config file (which, though, has to be passed as argument too). Example of config for collector with comments:

# Sheet owner is an email of user to whom ownership will be transfered
sheet_owner: s@example.com

# Credentials file is a JSON key which should be given to some service account.
# To understand how to create service account, try to google about a bit
google_spreadsheet_credentials_path: ~/Development/personal/backupreporter_key.json

# This is a name for a target spreadsheet
spreadsheet_name: "Backup-Reports"

# Sheet name in a spreadsheet
worksheet_name: Customers

bucket:
    - s3_path: s3://bucket/metadata/metadata.json
      aws_access_key_id: access-key
      aws_secret_access_key: secret-key
      aws_region: ru-1
      aws_endpoint_url: https://s3.ru-1.storage.selcloud.ru
      customer: Personal

Owner transfership at Google Drive

Spreadsheet Ownership Transfer

Transferring ownership of a Google Spreadsheet is a two-step process:

  1. Initiation The collector marks the spreadsheet with a flag indicating that ownership needs to be transferred.

  2. Acceptance The intended new owner must manually accept ownership by:

    • Opening Google Drive
    • Searching for pendingowner:me
    • Locating the corresponding spreadsheet
    • Accepting the ownership transfer

More information: Google Docs Help: Transfer ownership of a file


Alternative: Share Spreadsheet with Service Account (No Ownership Transfer)

Instead of transferring ownership, you can create the spreadsheet manually and share it with the service account.

  • Note: Ownership remains with you — the service account is only granted access.
  • Required permissions: Editor
  • Service account email: Found in the JSON credentials file referenced by the google_spreadsheet_credentials_path configuration option.

This method allows the service account to read and update the spreadsheet content, but not to manage sharing settings or transfer ownership.

Development

Install dependencies for local development:

make prepare
poetry install   # or: . .venv/bin/activate && poetry install

Run the tool via poetry run backup-reporter (or activate .venv first).

Releasing to PyPI

Release flow (local macOS or CI on Ubuntu):

make prepare
make build          # patch bump, commit, tag, build dist/
make publish        # requires PYPI_API_TOKEN
make push-release   # push commit and tags to origin

Requirements:

  • Clean git working tree (no uncommitted changes).
  • At least one new commit since the latest release tag.
  • Always run make push-release after a successful publish so git tags stay in sync with PyPI.

Set credentials locally:

export PYPI_API_TOKEN=pypi-...

CI uses GitHub Actions workflow .github/workflows/release.yml (workflow_dispatch) with repository secret PYPI_API_TOKEN.

If PyPI is ahead of git tags (e.g. tag was not pushed), the next make build creates a recovery release with the next patch version. Use RELEASE_STRICT=1 to fail instead of auto-recovery.

Authors

Made in cooperation with:

Metadata

Release files for backup-reporter 0.5.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backup-reporter 0.5.10
File Size Uploaded
backup_reporter-0.5.10.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for backup-reporter 0.5.10
File Interpreter ABI Platform
backup_reporter-0.5.10-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / backup_reporter-0.5.10.tar.gz

Download URL backup_reporter-0.5.10.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
abcbf30727860096a15f09ff126c387e793faa3cf295dbc4bd8147ca2e998b52
BLAKE2b-256 checksum
How to use checksums
da894724c2c60e2c57c5094eaf0122133f4e1a00cd3ad84ff449bf34a2a05d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1013-azure

Release files / backup_reporter-0.5.10-py3-none-any.whl

Download URL backup_reporter-0.5.10-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7709f6948540174d68f34db9dedb5eed5c14e186a2adb7aaf759da5dac405191
BLAKE2b-256 checksum
How to use checksums
c95293f49ef65dc2213dc962f168a900227b64a249d45bdf27f9c4fdb42e0663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1013-azure

Release history Release notifications | RSS feed

This release

0.5.10 This release

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page