string Runs the rollback migrations defined in the plan file.
```
### mattermost db init
Description
Initializes the database for a given data source name (DSN), executes migrations, and loads custom defaults when specified.
Format
``` sh
mattermost db init
```
Examples
Use the `config` flag to pass the DSN:
``` sh
mattermost db init --config postgres://localhost/mattermost
```
Run this command to use the `MM_CONFIG` environment variable:
``` sh
MM_CONFIG=postgres://localhost/mattermost mattermost db init
```
Run this command to set a custom defaults file to be loaded into the database:
``` sh
MM_CUSTOM_DEFAULTS_PATH=custom.json MM_CONFIG=postgres://localhost/mattermost mattermost db init
```
### mattermost db migrate
Description
Migrates the database schema if there are any unapplied migrations.
Child Commands
- [mattermost db downgrade](#mattermost-db-downgrade) - Roll back database migrations.
Format
``` sh
mattermost db migrate
```
Example
``` sh
mattermost db migrate
```
Options
``` text
--auto-recover bool If the migration plan receives an error during migrations, this command will try to rollback migrations already applied within the plan. Not recommended without reviewing migration plan by combining --save-plan and --dry-run options.
--save-plan bool Saves the plan for the migration into the file store so that it can be used for reviewing the plan or for downgrading.
--dry-run bool Does not apply the migrations, but it validates how the migration would run based on the given conditions.
```
### mattermost db reset
Description
Resets the database to its initial state. Doesn't start the application server. Only starts the store layer and truncates the tables, excluding the `migrations` table.
Format
``` sh
mattermost db reset
```
Example
``` sh
bin/mattermost db reset
```
### mattermost db version
Description
Returns the most recently applied version number.
Format
``` sh
mattermost db version
```
------------------------------------------------------------------------------------------------------------------------
## mattermost export
Description
Commands for exporting data for compliance and for merging multiple Mattermost instances.
Child Commands
- [mattermost export actiance](#mattermost-export-actiance) - Deprecated from Mattermost v10.5 in favor of [mattermost export schedule](#mattermost-export-schedule).
- [mattermost export csv](#mattermost-export-csv) - Deprecated from Mattermost v10.5.
- [mattermost export global-relay-zip](#mattermost-export-global-relay-zip) - Deprecated from Mattermost v10.5.
- [mattermost export schedule](#mattermost-export-schedule) - Schedule a compliance export job.
- [mattermost export bulk](#mattermost-export-bulk) - Export data to a file compatible with the Mattermost [bulk import format](/administration-guide/onboard/bulk-loading-data). Deprecated in favor of [mmctl export commands](/administration-guide/manage/mmctl-command-line-tool#mmctl-export).
### mattermost export actiance
From Mattermost v10.5, this command has been deprecated. It will be added to the mmctl command line tool in a future version. Until then, please use [mattermost export schedule](#mattermost-export-schedule).
### mattermost export csv
From Mattermost v10.5, this command has been deprecated. It will be added to the mmctl command line tool in a future version.
### mattermost export global-relay-zip
From Mattermost v10.5, this command has been deprecated. It will be added to the mmctl command line tool in a future version.
### mattermost export schedule
Description
Schedule an export job in a format suitable for importing into a third-party archive system.
Format
``` sh
mattermost export schedule
```
Example
``` sh
bin/mattermost export schedule --exportFrom=1513102632
```
Options
``` text
--exportFrom string Unix timestamp (seconds since epoch, UTC) to export data from.
--timeoutSeconds string Set how long the export should run for before timing out.
```
### mattermost export bulk
From Mattermost v6.0, this command has been deprecated in favor of [mmctl export commands](/administration-guide/manage/mmctl-command-line-tool#mmctl-export) as the supported way to export data out of Mattermost.
------------------------------------------------------------------------------------------------------------------------
## mattermost help
Description
Generate full documentation in Markdown format for the Mattermost command line tools.
Format
``` sh
mattermost help {outputdir}
```
------------------------------------------------------------------------------------------------------------------------
## mattermost import
Description
Import data into Mattermost.
Child Command
- [mattermost import bulk](#mattermost-import-bulk) - Import a Mattermost bulk import file. Deprecated in favor of [mmctl import commands](/administration-guide/manage/mmctl-command-line-tool#mmctl-import).
### mattermost import bulk
From Mattermost v6.0, this command has been deprecated in favor of [mmctl import commands](/administration-guide/manage/mmctl-command-line-tool#mmctl-import) as the supported way to import data into Mattermost.
------------------------------------------------------------------------------------------------------------------------
## mattermost jobserver
Description
Start the Mattermost job server.
Format
``` sh
mattermost jobserver
```
Example
``` sh
bin/mattermost jobserver
```
------------------------------------------------------------------------------------------------------------------------
## mattermost server
Description
Runs the Mattermost server.
Format
``` sh
mattermost server
```
------------------------------------------------------------------------------------------------------------------------
## mattermost version
From Mattermost v6.5, this CLI command no longer interacts with the database. The [mattermost db migrate](/administration-guide/manage/command-line-tools#mattermost-db-migrate) CLI command has been introduced to trigger schema migrations.
Desription
Displays Mattermost version information.
Format
``` sh
mattermost version
```
------------------------------------------------------------------------------------------------------------------------
## Troubleshooting
### Executing a command hangs and doesn't complete
If you have Bleve search indexing enabled, temporarily disable it in **System Console \> Experimental \> Bleve** and run the command again. You can also optionally use the new [mmctl Command Line Tool](/administration-guide/manage/mmctl-command-line-tool).
Bleve does not support multiple processes opening and manipulating the same index. Therefore, if the Mattermost server is running, an attempt to run the CLI will lock when trying to open the indeces.
If you aren't using the Bleve search indexing, feel free to post in our [Troubleshooting forum](https://forum.mattermost.com/c/trouble-shoot/16) to get help.