A pure-Go library for reading Microsoft Tape Format (MTF) streams - the
format produced by NTBACKUP.EXE and commonly found in .bkf backup files.
Features media spanning, transparent decompression, sparse reconstruction, Media Based Catalog parsing, and near-zero-allocation classification.
- Typed block iterator -
Nextyields media/set/entry/set-end blocks; a medium's role is self-evident from the sequence. - Faithful extraction - NTFS security descriptors, extended attributes,
sparse maps, and every remaining stream are auto-materialized onto the
Header; sparse files are reconstructed (holes zero-filled). - Transparent decompression - Stac LZS (
MTF_LZS221) and the compression/encryption frame layer; encryption via a pluggable decryptor (the spec defines no cipher). - Multi-media spanning — reassembles a data set split across media,
including mid-file splits. The
Continuationcallback gives the application full context (tape name, family ID, sequence) to prompt an operator. - Media Based Catalog - standard Type 1 Set Map / File/Directory Detail
parsing, auto-detected Backup Exec XML catalogs, and a
becatalogcompanion for vendor-specific payloads. - Media family identification -
Family()combines the TAPE block and Set Map to tell you the family ID, total tape count, and which data sets live on which tapes. Essential for the "I have one tape, what do I need?" use case.
r, err := mtf.Open("backup.bkf")
if err != nil { log.Fatal(err) }
defer r.Close()
for {
b, err := r.Next()
if err == io.EOF { break }
if err != nil { log.Fatal(err) }
switch b.Kind {
case mtf.KindEntry:
fmt.Println(b.Header.Name)
if b.Header.Type == mtf.EntryFile {
io.Copy(os.Stdout, r) // stream file content
}
case mtf.KindSetEnd:
fmt.Println("data set ended; catalog:", b.Catalog != nil)
}
}Full reference lives in docs/:
- Quick start - open, list, extract
- Reader API -
Next/Read, block kinds,Headerfields - Data streams - metadata, sparse, compression/encryption
- Media Based Catalog - Set Map, FDD,
CatalogData - Spanning - multi-media continuation with operator prompts
- LTO tapes - reading from LTO tape drives
- Backup Exec catalogs - the
becatalogpackage - Census - cartridge classification
- Performance - allocation strategy & benchmarks
- Architecture - package layout & reader pipeline
- Spec reference - MTF field offsets & checksums
These are small utilities built on the library, primarily for surveying archives:
| Tool | Purpose |
|---|---|
cmd/bkfscan |
Parallel .bkf surveyor using Census. |
cmd/bkfcensus |
Single-file Census reporter. |
bkfscan /mnt/archive/BEData # survey
go-mtf/
mtf.go public types & constants
reader.go the block iterator
header.go field accessors & offsets
strings.go MTF string decoding
datetime.go date/time decoding
streams.go data-stream materialization & sparse
catalog.go Media Based Catalog (standard)
spanning.go multi-media continuation
compress.go compression/encryption frames
lzs.go Stac LZS decompressor
census.go cartridge classification
becatalog/ Backup Exec XML catalog parser
cmd/ bkfscan, bkfcensus (survey utilities)
docs/ detailed documentation
MIT. See LICENSE.