## 11 `mfdbtool` ¶

The `mfdbtool` utility manages `mailfromd` databases.

### 11.1 Invoking `mfdbtool` ¶

The following options request the operation to be performed on the database. Exactly one of them must be specified. Each of them implied the `--stderr` option (see --stderr).

`--list` ¶

  List the database. By default, ‘`cache`’ database is assumed. To list another database, use `--format` option (see --format).

  See Basic Database Operations.

`--delete` ¶

  Delete given entries from the database (see deleting from databases). By default, ‘`cache`’ database is assumed. To specify another database, use `--format` option (see --format).

  See Basic Database Operations.

`--expire` ¶

  Delete all expired entries from the database (see Database Maintenance). By default, ‘`cache`’ database is assumed. To specify another database, use `--format` option (see --format). Full database name can be given in the command line (see `--file` option below), if it differs from the one specified in the script file.

  Use with the option `--all` (see --all) to expire all databases.

  See Database Maintenance.

`--compact` ¶

  Compact database (see compaction). By default, ‘`cache`’ database is compacted. To specify another database, use `--format` option (see --format). Full database name can be given in the command line (see `--file` option below), if it differs from the one specified in the script file.

  Use with the option `--all` (see --all) to compact all databases.

  See compaction.

The following options modify the behavior of `mfdbtool`:

`--all` ¶

  When used with `--compact` or `--expire` option, applies the action to all available databases. See compact cronjob.

`-d string` ¶
`--debug=string`

  Sets debugging level. The string argument must be a valid mailfromd debug level specification, as described in debugging level specification.

`-e interval` ¶
`--expire-interval=interval`

  Set expiration intervals for all databases to the specified interval. See time interval specification, for a description of interval format. The option overrides the `expire-interval` configuration statement (see expire-interval-conf), which you are advised to use instead.

`-f filename` ¶
`--file=filename`

  Set the name of the database to operate upon (for `--compact`, `--delete`, `--expire`, and `--list` options). Useful if, for some reason, you need to operate on a database whose file name does not match the one `mfdbtool` is configured to use.

`-H dbformat` ¶
`--format=dbformat`

  Use database of the given format, instead of the default ‘`cache`’. See Basic Database Operations.

`--ignore-failed-reads` ¶

  Ignore records that cannot be retrieved while compacting the database. Without this option, `mfdbtool` will abort the compaction if any such error is encountered.

`--predict=rate-limit` ¶

  Used with `--list` enables printing of the estimated times of sending along with the ‘`rate`’ database dump. Implies `--list --format=rate`. See estimated time of sending.

`--state-directory=dir` ¶

  Sets program state directory. See Local state directory, for the description of this directory and its purposes. This option overrides the `state-directory` configuration statement, described in state-directory.

`--time-format=format` ¶

  Set format to be used for timestamps in listings, produced by `--list`. The format is any valid `strftime` format string, see Time and Date Formats, for a detailed description. The default format is ‘`%c`’ (see %c time format). To analyze `mfdbtool --list` output using text tools, such as `awk` or `grep`, the following format might be useful: ‘`%s`’ (see %s time format). Another format I find useful is ‘`%Y-%m-%d_%H:%M:%S`’.

### 11.2 Configuring `mfdbtool` ¶

Configuration settings are read from the `/etc/mailfromd.conf` file (see Configuring `mailfromd`). The following statements are understood:

Statement | Reference
--- | ---
`database` | See Database Configuration.
`database-mode` | See database-mode.
`database-type` | See database-type.
`debug` | See `calloutd` logging.
`lock-retry-count` | See lock-retry-count.
`lock-retry-timeout` | See lock-retry-timeout.
`state-directory` | See state-directory.