{"id":49283520,"url":"https://github.com/impossibleforge/pfc-archiver-cratedb","last_synced_at":"2026-04-25T20:03:19.141Z","repository":{"id":351781089,"uuid":"1212390732","full_name":"ImpossibleForge/pfc-archiver-cratedb","owner":"ImpossibleForge","description":"Autonomous archive daemon for CrateDB cold storage","archived":false,"fork":false,"pushed_at":"2026-04-20T16:02:33.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-20T16:37:51.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImpossibleForge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-16T10:30:40.000Z","updated_at":"2026-04-20T16:02:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ImpossibleForge/pfc-archiver-cratedb","commit_stats":null,"previous_names":["impossibleforge/pfc-archiver","impossibleforge/pfc-archiver-cratedb"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ImpossibleForge/pfc-archiver-cratedb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-archiver-cratedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-archiver-cratedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-archiver-cratedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-archiver-cratedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImpossibleForge","download_url":"https://codeload.github.com/ImpossibleForge/pfc-archiver-cratedb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImpossibleForge%2Fpfc-archiver-cratedb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32274987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-25T20:03:09.961Z","updated_at":"2026-04-25T20:03:19.132Z","avatar_url":"https://github.com/ImpossibleForge.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pfc-archiver-cratedb — Autonomous archive daemon for CrateDB\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Python](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://python.org)\n[![PFC-JSONL](https://img.shields.io/badge/PFC--JSONL-v3.4-green.svg)](https://github.com/ImpossibleForge/pfc-jsonl)\n[![Version](https://img.shields.io/badge/pfc--archiver--cratedb-v0.1.0-brightgreen.svg)](https://github.com/ImpossibleForge/pfc-archiver-cratedb/releases)\n\nA standalone daemon that runs alongside CrateDB, watches for data older than a configurable retention window, compresses it to PFC format, and writes it to local storage or S3 — automatically.\n\n**Runs as a sidecar or cron job — no schema changes, no plugins, no CrateDB modifications.**\n\n---\n\n## How it works\n\nEvery `interval_seconds` (default: 3600), pfc-archiver-cratedb runs one archive cycle:\n\n```\nSCAN  -\u003e  EXPORT  -\u003e  COMPRESS  -\u003e  UPLOAD  -\u003e  VERIFY  -\u003e  (optional DELETE)  -\u003e  LOG\n```\n\n1. **SCAN** — compute which time partitions in CrateDB are older than `retention_days`\n2. **EXPORT** — read rows in `partition_days`-sized chunks via PostgreSQL wire protocol\n3. **COMPRESS** — pipe through `pfc_jsonl compress` → `.pfc` + `.pfc.bidx` + `.pfc.idx`\n4. **UPLOAD** — write to `output_dir` (local path or `s3://bucket/prefix/`)\n5. **VERIFY** — decompress and count rows; must match exported count exactly\n6. **DELETE** _(optional)_ — `DELETE WHERE ts \u003e= from AND ts \u003c to` (only if `delete_after_archive = true`)\n7. **LOG** — write a JSON run log to `log_dir`\n\n---\n\n## Supported databases\n\n| Database | Protocol | Default port |\n|----------|----------|-------------|\n| CrateDB | PostgreSQL wire (psycopg2) | 5432 |\n\n---\n\n## Install\n\n```bash\npip install pfc-archiver-cratedb\n\n# Or from source\ngit clone https://github.com/ImpossibleForge/pfc-archiver-cratedb\ncd pfc-archiver-cratedb\npip install -r requirements.txt\n```\n\n**The `pfc_jsonl` binary must be installed:**\n\n```bash\n# Linux x64:\ncurl -L https://github.com/ImpossibleForge/pfc-jsonl/releases/latest/download/pfc_jsonl-linux-x64 \\\n     -o /usr/local/bin/pfc_jsonl \u0026\u0026 chmod +x /usr/local/bin/pfc_jsonl\n\n# macOS (Apple Silicon M1–M4):\ncurl -L https://github.com/ImpossibleForge/pfc-jsonl/releases/latest/download/pfc_jsonl-macos-arm64 \\\n     -o /usr/local/bin/pfc_jsonl \u0026\u0026 chmod +x /usr/local/bin/pfc_jsonl\n```\n\n\u003e **License note:** This tool requires the `pfc_jsonl` binary. `pfc_jsonl` is free for personal and open-source use — commercial use requires a separate license. See [pfc-jsonl](https://github.com/ImpossibleForge/pfc-jsonl) for details.\n\n\u003e **macOS Intel (x64):** Binary coming soon.\n\u003e **Windows:** No native binary. Use WSL2 or a Linux machine.\n\n**Python dependency for CrateDB:**\n\n```bash\npip install psycopg2-binary\n```\n\n---\n\n## Quick start\n\n```bash\n# 1. Copy the example config\ncp config/cratedb.toml my_config.toml\n\n# 2. Edit the config\nnano my_config.toml\n\n# 3. Dry run (no writes, prints what would be archived)\npython pfc_archiver.py --config my_config.toml --dry-run\n\n# 4. Archive once and exit\npython pfc_archiver.py --config my_config.toml --once\n\n# 5. Run as a daemon (loops every interval_seconds)\npython pfc_archiver.py --config my_config.toml\n```\n\n---\n\n## Configuration\n\nAll config is TOML. A complete example is in `config/cratedb.toml`.\n\n```toml\n[db]\ndb_type   = \"cratedb\"\nhost      = \"localhost\"\nport      = 5432\nuser      = \"crate\"\npassword  = \"\"\ndatabase  = \"doc\"\nschema    = \"doc\"\ntable     = \"logs\"\nts_column = \"ts\"             # your timestamp column\nbatch_size = 10000\n\n[archive]\nretention_days       = 30         # archive data older than this many days\npartition_days       = 1          # export this many days per archive file\noutput_dir           = \"./archives/\"   # local path or s3://bucket/prefix/\nverify               = true       # decompress + count rows after each archive\ndelete_after_archive = false      # DELETE rows from CrateDB after successful verify\nlog_dir              = \"./archive_logs/\"\n\n[daemon]\ninterval_seconds = 3600           # how often to run (in daemon mode)\n```\n\n---\n\n## Output format\n\nEach archive cycle produces files named:\n\n```\n\u003cschema\u003e__\u003ctable\u003e__\u003cYYYYMMDD\u003e__\u003cYYYYMMDD\u003e.pfc\n\u003cschema\u003e__\u003ctable\u003e__\u003cYYYYMMDD\u003e__\u003cYYYYMMDD\u003e.pfc.bidx\n\u003cschema\u003e__\u003ctable\u003e__\u003cYYYYMMDD\u003e__\u003cYYYYMMDD\u003e.pfc.idx\n```\n\nThe `.pfc` file is a PFC-JSONL archive. The `.bidx` and `.idx` files are block indexes that let DuckDB decompress only the relevant time window — without reading the whole file.\n\n---\n\n## Log format\n\nEach completed cycle appends a JSON entry to `\u003clog_dir\u003e/archive_\u003cYYYYMMDD\u003e.log`:\n\n```json\n{\n  \"ts\":          \"2026-04-14T18:00:00\",\n  \"db\":          \"cratedb://localhost:5432/doc\",\n  \"table\":       \"logs\",\n  \"from\":        \"2026-03-01T00:00:00\",\n  \"to\":          \"2026-03-02T00:00:00\",\n  \"rows\":        248721,\n  \"jsonl_mb\":    42.3,\n  \"pfc_mb\":      2.5,\n  \"ratio_pct\":   5.9,\n  \"output\":      \"./archives/doc__logs__20260301__20260302.pfc\",\n  \"verified\":    true,\n  \"deleted\":     false,\n  \"status\":      \"ok\"\n}\n```\n\n---\n\n## Run as a systemd service\n\n```ini\n[Unit]\nDescription=pfc-archiver-cratedb — PFC archive daemon for CrateDB\nAfter=network.target\n\n[Service]\nType=simple\nUser=pfc\nWorkingDirectory=/opt/pfc-archiver-cratedb\nExecStart=/usr/bin/python3 /opt/pfc-archiver-cratedb/pfc_archiver.py --config /etc/pfc-archiver-cratedb/cratedb.toml\nRestart=on-failure\nRestartSec=60\n\n[Install]\nWantedBy=multi-user.target\n```\n\n```bash\nsudo systemctl enable pfc-archiver-cratedb\nsudo systemctl start pfc-archiver-cratedb\nsudo journalctl -u pfc-archiver-cratedb -f\n```\n\n---\n\n## Run as a Docker sidecar\n\n```yaml\n# docker-compose.yml\nservices:\n  cratedb:\n    image: crate:latest\n    ports: [\"4200:4200\", \"5432:5432\"]\n\n  pfc-archiver-cratedb:\n    image: ghcr.io/impossibleforge/pfc-archiver-cratedb:latest\n    volumes:\n      - ./config/cratedb.toml:/etc/pfc-archiver-cratedb/config.toml\n      - ./archives:/archives\n      - ./archive_logs:/logs\n    environment:\n      - PFC_CONFIG=/etc/pfc-archiver-cratedb/config.toml\n    depends_on: [cratedb]\n```\n\n---\n\n## Deleting archived data\n\n`delete_after_archive = false` by default — pfc-archiver-cratedb never modifies your CrateDB without explicit opt-in.\n\nAfter confirming your archives are accessible via DuckDB, set `delete_after_archive = true` and restart. Only partitions that pass the row-count verify step will be deleted.\n\n```sql\n-- Manual deletion if needed\nDELETE FROM logs WHERE ts \u003e= '2026-03-01' AND ts \u003c '2026-03-02'\n```\n\n---\n\n## Querying cold archives\n\nOnce archived, your `.pfc` files are queryable directly from DuckDB — alongside live CrateDB data:\n\n```sql\nINSTALL pfc FROM community;\nLOAD pfc;\nLOAD json;\n\n-- Scan a single archive\nSELECT *\nFROM read_pfc_jsonl('./archives/doc__logs__20260301__20260302.pfc')\nLIMIT 100;\n\n-- Time-window query (only decompresses the relevant blocks)\nSELECT *\nFROM read_pfc_jsonl(\n    './archives/doc__logs__20260301__20260302.pfc',\n    ts_from = epoch(TIMESTAMPTZ '2026-03-01 14:00:00+00'),\n    ts_to   = epoch(TIMESTAMPTZ '2026-03-01 15:00:00+00')\n);\n\n-- Hybrid: cold PFC archives + live CrateDB in one query\n-- See: https://github.com/ImpossibleForge/pfc-migrate/blob/main/examples/cratedb_archive_explorer.py\n```\n\n---\n\n## Related Projects\n\n| Project | Description |\n|---------|-------------|\n| [pfc-jsonl](https://github.com/ImpossibleForge/pfc-jsonl) | Core binary — compress, decompress, query |\n| [pfc-duckdb](https://github.com/ImpossibleForge/pfc-duckdb) | DuckDB Community Extension (`INSTALL pfc FROM community`) |\n| [pfc-migrate](https://github.com/ImpossibleForge/pfc-migrate) | One-shot CrateDB export and JSONL archive conversion |\n| [pfc-fluentbit](https://github.com/ImpossibleForge/pfc-fluentbit) | Fluent Bit -\u003e PFC forwarder for live pipelines |\n| [pfc-vector](https://github.com/ImpossibleForge/pfc-vector) | High-performance Rust ingest daemon for Vector.dev and Telegraf |\n| [pfc-otel-collector](https://github.com/ImpossibleForge/pfc-otel-collector) | OpenTelemetry OTLP/HTTP log exporter |\n| [pfc-kafka-consumer](https://github.com/ImpossibleForge/pfc-kafka-consumer) | Kafka / Redpanda consumer |\n| [pfc-telegraf](https://github.com/ImpossibleForge/pfc-telegraf) | Telegraf HTTP output plugin → PFC |\n| [pfc-grafana](https://github.com/ImpossibleForge/pfc-grafana) | Grafana data source plugin for PFC archives |\n\n---\n\n\n---\n\n## Disclaimer\n\nPFC-Archiver-CrateDB is an independent open-source project and is not affiliated with, endorsed by, or associated with Crate.io or CrateDB.\n## License\n\npfc-archiver-cratedb (this repository) is released under the MIT License — see [LICENSE](LICENSE).\n\nThe PFC-JSONL binary (`pfc_jsonl`) is proprietary software — free for personal and open-source use. Commercial use requires a license: [info@impossibleforge.com](mailto:info@impossibleforge.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpossibleforge%2Fpfc-archiver-cratedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimpossibleforge%2Fpfc-archiver-cratedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpossibleforge%2Fpfc-archiver-cratedb/lists"}