NAME

KiokuDB::Cmd::Command::Dump - Dump database entries for backup or munging purposes

SYNOPSIS

# command line API
# dump whole database to foo.yml sequentially

% kiokudump --verbose --file foo.yml --format yaml --backup --dsn bdb-gin:dir=data/



# programmatic API

use KiokuDB::Cmd::Command::Dump;

my $dumper = KiokuDB::Cmd::Command::Dump->new(
    backend => $backend,
    formatter => sub { ... },
    output_handle => $fh,
);

$dumper->run;

DESCRIPTION

Using the KiokuDB::Backend::Role::Scan interface, any supporting backend can be dumped using this api.

The data can then be edited or simply retained for backup purposes.

The data can be loaded using KiokuDB::Cmd::Command::Load.

COMMAND LINE API

This class uses MooseX::Getopt to provide a command line api.

The command line options map to the class attributes.

METHODS

new_with_options

Provided by MooseX::Getopt. Parses attributes init args from @ARGV.

run

Performs the actual dump.

ATTRIBUTES

dsn
backend

The backend to be dumped.

dsn is a string and thus can be used on the command line. backend is defined in terms of dsn if it isn't provided.

format
formatter

format is one of yaml, storable or json, defaulting to yaml.

formatter is a code reference which takes an entry as an argument. It is created from a set of defaults using format if it isn't provided.

file
backup
force
backup_ext
output_handle

output_handle is where the returned string of formatter will be printed.

If it isn't provided, file will be opened for writing. If the file already exists and force is specified, it will be overwritten. If backup is provided the original will first be renamed using backup_ext (defaults to .bak). If the backup already exists, then force will allow overwriting of the previous backup.

If no file is provided then STDOUT is used.

verbose

If enabled causes progress information to be printed to STDERR.