← All tools

dbsmedya/goarchive

Popularity 65 Updated Development & Build

Foreign-key-aware MySQL archiver: archive, copy, or purge a parent row with its entire child subgraph — dependency-ordered, verified before delete, crash-recoverable.

githubauto-collected

Installation

A directly usable install command is not verified yet. Check the project documentation or releases.

GoArchive — Foreign-Key-Aware MySQL Archiver for Related Tables

Archive, copy, or purge a parent row together with every child row that depends on it — in dependency order, verified before anything is deleted.

GoArchive is a Go CLI tool for archiving MySQL relational data across servers. Unlike single-table archivers, it resolves foreign-key dependencies automatically using Kahn's topological sort, so deleting old orders never leaves orphaned orderitems behind. Each batch is verified by row count or SHA256 before source rows are deleted, and an interrupted run resumes from a persistent checkpoint.

What problem does this solve?

You need to delete or archive old data from a production MySQL database, but those rows have children:

  • Deleting old orders orphans orderitems, orderpayments, and shipments
  • Deleting old customers breaks foreign keys three levels deep
  • ON DELETE CASCADE silently removes rows you never archived
  • Single-table archivers move the parent and leave the children behind
  • Deleting in the wrong order fails with MySQL Error 1451 (Cannot delete or update a parent row)

GoArchive takes a declared parent-child relation tree, discovers every dependent row by BFS traversal, copies the whole subgraph to an archive server parent-first, verifies it arrived intact, then deletes from the source child-first.

Typical uses: MySQL data retention and GDPR right-to-erasure · shrinking oversized tables to restore query performance · moving cold data to an archive server · purging staging data while preserving referential integrity.

GoArchive vs pt-archiver

pt-archiver is the mature, widely-adopted standard for MySQL archiving, and it remains the better choice for most work. Use pt-archiver when you are archiving a single table, or need file/CSV output, LOAD DATA INFILE bulk loading, composite primary keys, MyISAM, MySQL 5.x, progress reporting, or multi-replica lag checks.

GoArchive exists for the one case pt-archiver cannot express without writing a Perl plugin: archiving a parent row together with its child subgraph. It adds verification before deletion and persistent crash recovery.

| | pt-archiver | GoArchive | |---|---|---| | Tables per run | one | root + full child subgraph | | Dependency ordering | manual, via plugin | automatic (Kahn's algorithm) | | Verify copy before delete | ❌ | ✅ count or SHA256 | | Crash recovery / resume | ❌ | ✅ per-row checkpoint | | Foreign key coverage check | ❌ | ✅ blocks uncovered FKs | | Composite / non-integer PKs | ✅ | ❌ | | File / CSV output | ✅ | ❌ | | MyISAM, MySQL 5.x | ✅ | ❌ | | Progress & statistics output | ✅ | ❌ | | Maturity | ~19 years | ~6 months |

Many teams use both: pt-archiver for high-volume single-table nibbling, GoArchive for relational subgraphs where ordering and verification matter more than raw throughput.

Is GoArchive right for your schema?

Requires:

  • MySQL 8.0+ with the InnoDB storage engine
  • A single-column PRIMARY KEY on every participating table
  • An integer primary key on the root table (child tables may use any single-column type)
  • 1:1 or 1:N relationships

Not supported: composite (multi-column) primary keys · UUID, VARCHAR, or datetime root keys · many-to-many (N:M) join tables as first-class citizens · self-referential tree hierarchies · MyISAM · MySQL 5.x · INVISIBLE columns.

Preflight rejects an unsupported schema before any data moves — see Limitations for the full list and Validation for what each check does.