The mitto Command

mitto

The main entry point

mitto [OPTIONS] COMMAND [ARGS]...

Options

--logfile <logfile>
--loglevel <loglevel>

backup

Creates a backup file containing all Mitto application data.

The backup file will contain the files located in the directory specified by MITTO_DATA, and the data stored in the database specified by DATABASE_URL. Note that ANALYTICS_DATABASE_URL is not included in the backup.

The files and data are backed up in a single gzipped tar archive file named FILE. If FILE exists, the command exits with an exit code of 1.

FILE specifies the name of the file in which the backup will be saved. If the filename component is preceded by an optional filesystem path component, the file will be created in that directory. Otherwise, FILE is created in the current directory.

FILE (both the name component and the path component) may contain “mustache” templates supported by iov2.date_time_formatter. If FILE is not provided as an argument, it defaults to ‘mitto-{year}{month}{day}.tgz’.

Backing up a running Mitto system proceeds in this manner:

1. A temporary working directory is created.
2. ‘pg_dump’ is used to create a backup of $DATABASE_URL.
3. A compressed ‘tar’ archive, consisting of $MITTO_DATA and the just created
database backup , is created and placed in FILE.
4. Any intermediate files that were created are removed when the command exits.

OPTIONS

–fast –best –compression N

These options control the gzip compression level. The compression level
is specified by the digit ‘N’. If none of these options are present, a
compression level of ‘–compression 6’ is used (biased toward high
compression at the expense of speed). ‘–compression 1’ or ‘–fast’ are
the fastest and least CPU intensive, but create the largest backups.
‘–compression 9’ or ‘–best create the smallest backups, but are the
slowest and most CPU intensive.

RETURN VALUE

The exit code indicates whether the backup was successful, and if not, what type of error occurred.

0 - Successful backup.
1 - Error.

When a backup is unsuccessful, diagnostic information is logged and placed on stderr.

Current settings:

MITTO_DATA=/tmp/mitto

DATABASE_URL=postgresql://mitto:1234@db/test

mitto backup [OPTIONS] FILE

Options

-f, --force

overwrite FILE, if present

--fast

shortest time, biggest backup

--best

smallest backup, longest time

--compression <compression>

gzip compression level

Options:

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Arguments

FILE

Optional argument

config

Commands for config

mitto config [OPTIONS] COMMAND [ARGS]...

get

Get config value by key (including secrets)

mitto config get [OPTIONS] KEY

Arguments

KEY

Required argument

getall

Get all config values

mitto config getall [OPTIONS]

secret

Commands for secrets

mitto config secret [OPTIONS] COMMAND [ARGS]...
delete

Delete secret value by key

mitto config secret delete [OPTIONS] KEY

Arguments

KEY

Required argument

get

Get secret value by key

mitto config secret get [OPTIONS] KEY

Arguments

KEY

Required argument

getall

Get all secret values

mitto config secret getall [OPTIONS]
set

Set secret value by key

mitto config secret set [OPTIONS] KEY VALUE

Arguments

KEY

Required argument

VALUE

Required argument

configure

Configure a new system.

mitto configure [OPTIONS] HOSTNAME

Options

--username <username>
Default:

admin

--password <password>

New password. Can be provided via ‘MITTO_PASSWORD’ env variable. If not set - input prompt will be used.

--ifnx

If doesn’t exist

Default:

False

Arguments

HOSTNAME

Required argument

Environment variables

MITTO_HOSTNAME

Provide a default for HOSTNAME

MITTO_PASSWORD

Provide a default for --password

credentials

Commands for credentials

mitto credentials [OPTIONS] COMMAND [ARGS]...

decrypt

Decrypt credentials by name

mitto credentials decrypt [OPTIONS] NAME

Arguments

NAME

Required argument

initdb

mitto initdb [OPTIONS]

jobs

Commands for jobs

mitto jobs [OPTIONS] COMMAND [ARGS]...

install

Install a job by path

mitto jobs install [OPTIONS] PATH

Arguments

PATH

Required argument

kill

Kill a running job

mitto jobs kill [OPTIONS] NAME

Arguments

NAME

Required argument

remove

Remove a job by name or id

mitto jobs remove [OPTIONS] NAME

Arguments

NAME

Required argument

run

Run a job by name, ID or config path and wait for completion. An example:

  • mitto jobs run job_name

  • mitto jobs run 123

  • mitto jobs run –job_type=io ./path/job_config.json

    NOTE: In this use-case, the path to the config file path must contain a ‘/’, otherwise, it will be treated as a job name.

mitto jobs run [OPTIONS] NAME

Options

--job_type <job_type>

Job type.

--params <params>

Optionals params for job.

Arguments

NAME

Required argument

run_async_cmd

Run a job by name or ID and wait for completion.

mitto jobs run_async_cmd [OPTIONS] NAME

Options

--params <params>

Optionals params for job.

Arguments

NAME

Required argument

runner

Getting current state [enabled|disabled], nested commands for making changes

mitto jobs runner [OPTIONS] COMMAND [ARGS]...
disabled

Disable running new jobs

mitto jobs runner disabled [OPTIONS] [TIMEOUT]

Options

--wait

Wait for the end of running jobs

Default:

False

Arguments

TIMEOUT

Optional argument

enabled

Enable running new jobs

mitto jobs runner enabled [OPTIONS]

start

Start a Job.

mitto jobs start [OPTIONS] NAME

Arguments

NAME

Required argument

license

Commands for credenlicensetials

mitto license [OPTIONS] COMMAND [ARGS]...

refresh

Refresh license and print installed plugins

mitto license refresh [OPTIONS]

Options

--outfile <outfile>

migrate

Perform a database migration

mitto migrate [OPTIONS]

password

Allows to change the admin or user password. Unable to set another password for the admin then a value of ‘PASSWORD’ environment variable.

Also resets the ‘failed_login_attempts’ value. Means the user instance receives an unlocked status.

Example:

To change admin password: >>> mitto password To change user password: >>> mitto password –user username

mitto password [OPTIONS]

Options

--user <user>

plugins

Commands for plugins

mitto plugins [OPTIONS] COMMAND [ARGS]...

list

List of installed plugins

mitto plugins list [OPTIONS]

Options

--outfile <outfile>

prune_table

Remove (prune) “old” records from a database table.

By default, this command prunes old records from the mitto.status table.

The mitto.status table contains the history of job runs on the instance. When this table grows to contain more than a few hundred thousand rows, it can begin to negatively affect system performance. Periodic use of this command to remove the oldest rows can help ensure peak performance of a Runner instance..

Examples:

1. Prune the mitto.status table, removing all rows where the completed_at
value is 3 months old or older:
mitto prune_table
2. Prune the mitto.status table using a custom field and time interval:
mitto prune_table –field-name started_at –interval ‘7 days’
3. Prune a custom table using a specific DB connection URL:
mitto prune_table –table-name job_log –dbo postgresql://user:password@host:port/db
4. Use a smaller batch size of 100:
mitto prune_table -b 100
Note: Use of a batch size larger than the default of 1000 increases the risk of the table
being locked for extended periods of time.
mitto prune_table [OPTIONS]

Options

-d, --dbo <dbo>

Database connection URL (e.g. postgresql://mitto:1234:5432/mitto)

-b, --batch-size <batch_size>

Number of rows to delete per chunk. Note that using a value larger than the default increases the risk of database locks delaying other database operations.

-t, --table-name <table_name>

Required Table name to prune

-f, --field-name <field_name>

Field name to check against the interval (default: ‘completed_at’).

-i, --interval <interval>

Time interval after which data will be deleted. Older rows, falling outside the interval, will be deleted. Examples:

‘7 days’ — delete rows more than 7 days old ‘3 months’ — delete rows more than 3 months old ‘1 year’ — delete rows more than 1 year old

Note: The interval value must be a valid Postgres interval. See: https://www.postgresql.org/docs/current/functions-datetime.html

restore

Restores a Mitto system from backup. FILE must exist and it must be a Mitto backup previously created using ‘mitto backup’.

Restore from backup proceeds in this manner:

1. A new, empty, Mitto database is created
at $DATABASE_URL_{year}{month}{day}.
2. ‘psql’ is used to restore data to the database.
3. ‘tar’ is used to restore files to $MITTO_DATA. If, prior to the restore,
$MITTO_DATA contains files not present in FILE, those files will not be
affected (i.e., they will not be removed).
4. set up new DATABASE_URL to mitto.env and restart containers

If a failure occurs during any of these steps, the restore exits, leaving behind anything that may have been restored prior to the failure.

The –nosvcs option is intended for use by developers running a local instance of Mitto without any services. When present, the option inhibits start/stop of Mitto services which would otherwise cause numerous sudo/password prompts.

RETURN VALUE

The exit code indicates whether the restore was successful, and if not, what type of error occurred.

0 - Successful restore.
1 - Error.

When a restore is unsuccessful, diagnostic information is logged and placed on stderr.

mitto restore [OPTIONS] [FILE]

Options

--nosvcs

disable stop/start of Mitto services

Arguments

FILE

Optional argument

sample

Sample STRING as Python type PTYPE with existing column type CTYPE

for the specified Database (defaults to PostgreSQL). The same value could be sampled as a different type for the different target Databases depending on the target column type limitations.

 PTYPE: decimal.Decimal, float, int, str COLTYPE: BigInteger, Boolean, Date, DateTime, Float, Integer, NULL, NVARCHAR, Numeric, String, Text, Time DBNAME: (‘postgresql’, ‘snowflake’, ‘redshift’, ‘mysql’, ‘mariadb’, ‘mssql’, ‘bigquery’)

Examples:

 1. Determine how Mitto samples the string “1,234.59” if the

existing column does not have an SDL type.

$ mitto sample 1,234.59 str NULL

 2. Determine how Mitto samples the string “$1,234.59” if the

existing column does not have an SDL type. Note use of quoting to protect the dollar sign.

$ mitto sample ‘$1,234.59’ str NULL

 3. Determine how Mitto samples the string “-$1,234.59” if the

existing column does not have an SDL type. Note use of ‘–’ to signal the end of options.

$ mitto sample –verbose – ‘-$1,234.59’ str NULL $ mitto sample – ‘-$1,234.59’ str NULL

 4. Determine how Mitto samples the string “true” if the

existing column is SDL Boolean.

$ mitto sample true str Boolean

 5. Determine how Mitto samples the string

“11111111111111111111111111111111111111” if the existing column does not have an SDL type.

$ mitto sample -db redshift ‘11111111111111111111111111111111111111’

str NULL

mitto sample [OPTIONS] STRING PTYPE CTYPE

Options

-v, --verbose
-db, --dbname <dbname>
Options:

postgresql | snowflake | redshift | mysql | mariadb | mssql | bigquery

Arguments

STRING

Required argument

PTYPE

Required argument

CTYPE

Required argument

shell

Launch an interactive shell

mitto shell [OPTIONS]

store

Describe or dump the store named STORE_NAME

Examples:

 1. Print basic information about a store.

mitto store store_name

 2. Pretty-print the contents of the store using ‘jq’.

WARNING: for large stores, this may exhaust system memory. Note that JSON output is used here.

mitto store store_name –json | jq .

 3. Pretty-print the first row of a store using ‘jq’.

Note that the output format is JSONL, not JSON.



mitto store store_name –jsonl | sed 1q | jq .

or

mitto store store_name –jsonl –count 1 | jq .

 4. Test a jpath expression that you wish to use within

a Mitto job configuration.


mitto store netsuite_inventory_item –jsonl –count 1
jsonpath_ng ‘$.locationsList.locations’

 5. List all the first 100 keys in the store. 

mitto store netsuite_inventory_item –keys 100

 6. Get the value of key D655. 

mitto store netsuite_inventory_item –get D655

mitto store [OPTIONS] STORE_NAME

Options

-d, --describe

print basic information about STORE_NAME [default]

-j, --json

dump STORE_NAME to stdout as JSON

-l, --jsonl

dump STORE_NAME to stdout as JSONL

-c, --count <count>

number of rows to return

-k, --keys <keys>

dump up to KEYS keys from STORE_NAME

-g, --get <get>

dump value of the GET key from STORE_NAME to stdout

Arguments

STORE_NAME

Required argument

upload-file-policy

Commands for upload file policies

mitto upload-file-policy [OPTIONS] COMMAND [ARGS]...

add

Add upload file policy

mitto upload-file-policy add [OPTIONS] NAME

Options

--allowed-path <allowed_path>

Allowed path for uploading

Default:

external_uploads

--max-file-size-in-mb <max_file_size_in_mb>

Max file size in Mb

Default:

10

Arguments

NAME

Required argument

delete

Delete api key or upload file policy

mitto upload-file-policy delete [OPTIONS] API_KEY_ID [POLICY_ID]

Arguments

API_KEY_ID

Required argument

POLICY_ID

Optional argument

get

Get upload file policy

mitto upload-file-policy get [OPTIONS] API_KEY

Arguments

API_KEY

Required argument

list

List of upload file policies

mitto upload-file-policy list [OPTIONS]

version

Print mitto version.

mitto version [OPTIONS]