Skip to main content

ros2bag-repairer

Repair incomplete or corrupt rosbag2 (sqlite3 .db3) bags — the kind a recorder leaves behind when it's killed mid-run. No ROS 2 installation required; it works directly on the .db3 with the Python standard library and the sqlite3 CLI.

What it fixes

Symptom What happened Repair
ros2 bag play can't open the bag recorder died before writing metadata.yaml rebuild metadata.yaml from the messages in the .db3
messages missing / bag truncated a <bag>_0.db3-wal was never checkpointed fold the WAL back into the database
"database disk image is malformed" the .db3 is partially corrupt salvage with sqlite .recover (falls back to .dump), backing up the original

metadata.yaml is fully derivable from the database: the topics table holds every topic's name/type/serialization/QoS, and the messages table holds the counts and timestamps. The tool recomputes all of it (version 5, sqlite3), which is exactly what makes a metadata-less bag playable again.

Install

pip install -e .          # from this directory
# or run without installing:
python -m ros2bag_repairer.cli <bag>   # with src/ on PYTHONPATH

Requires Python ≥ 3.8, PyYAML, and the sqlite3 command-line tool (only needed for the corrupt-database recovery path).

Use

# Repair in place (rebuilds metadata.yaml; backs up any db it has to recover):
ros2bag-repair /data/recordings/zed_20260621_225845

# Or a single .db3 file:
ros2bag-repair /data/recordings/zed_20260621_225845/zed_20260621_225845_0.db3

# Write the repaired bag elsewhere, leaving the original untouched:
ros2bag-repair <bag> --output ~/bag_repair/zed_20260621_225845

# Force sqlite .recover even if the integrity check passes:
ros2bag-repair <bag> --force-recover

Then play it as usual:

ros2 bag play /data/recordings/zed_20260621_225845

Library API

from ros2bag_repairer import repair

report = repair("/data/recordings/zed_20260621_225845")
print(report.message_count, report.recovered, report.metadata_written)

How it works

  1. db.checkpoint_wal — merges a leftover -wal into the database.
  2. db.integrity_ok / db.recover — integrity-checks the .db3 and, if it fails, rebuilds it with sqlite .recover.
  3. metadata.build_metadata — reads topics + messages and recomputes the per-topic counts, the start time, and the duration.
  4. repairer.repair — orchestrates the above and writes metadata.yaml.

Test

python -m pytest -q          # or: python tests/test_repair.py via pytest

License

Apache-2.0.

Metadata

Release files for ros2bag-repairer 0.1.0

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

Source distribution (sdist)

Source distribution for ros2bag-repairer 0.1.0
File Size Uploaded Provenance
ros2bag_repairer-0.1.0.tar.gz 13.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ros2bag-repairer 0.1.0
File Interpreter ABI Platform
ros2bag_repairer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / ros2bag_repairer-0.1.0.tar.gz

Download URL ros2bag_repairer-0.1.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dff80a348d878a5ab4ded77aa410cb9215e19ddb8ccd452877ee76c55500209e
BLAKE2b-256 checksum
How to use checksums
31cc33fa05474c33b0953f4cdd71f6ae4c02dac70234c3637ac84bba1a3b7919
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / ros2bag_repairer-0.1.0-py3-none-any.whl

Download URL ros2bag_repairer-0.1.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69ce4b97e42462285fdc6303bd5f6e90a4100543e5193816e182c9e69220250f
BLAKE2b-256 checksum
How to use checksums
d953235f732a5c4d2d567dcf73b3dbe65603774d5d8d29b853c4924f0f7dda84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Security for ros2bag-repairer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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