create-index-snapshot

command
v0.31.9-decrease-wait-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Create Index Snapshot

Description

This utility binary creates snapshots of DPS state index databases. It uses the Badger backup API to create a single file snapshot of the database. Output is written to standard output and can be piped into a file if desired. The user can choose between various encoding and compression formats.

The index database can later be restored using the restore-index-snapshot tool.

Usage

Usage of create-index-snapshot:
  -c, --compression string   compression algorithm ("none", "zstd" or "gzip") (default "zstd")
  -e, --encoding string      output encoding ("none", "hex" or "base64") (default "none")
  -i, --index string         database directory for state index (default "index")

Examples

Usage

Outputting a hex-encoded zstd-compressed index snapshot on the console to use in testing:

$ create-index-snapshot -i /var/dps/index -c zstd -e hex

Back up an existing index database to a Gzip compressed file without encoding:

$ create-index-snapshot -i /var/dps/index -c gzip > dps-index-snapshot.gz
Go Program Restoring the Index

The program below opens a in-memory Badger database and restores the state from the created hex-encoded backup. Error handling is omitted for brevity.

opts := badger.DefaultOptions("").WithInMemory(true).WithLogger(nil)
db, _ := badger.Open(opts)

payload := "<pasted hex-encoded zstd-compressed output of create-index-snapshot>"

reader, _ := zstd.NewReader(hex.NewDecoder(strings.NewReader(payload)))
defer reader.Close()

db.Load(reader, 10)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL