Data import and export

    EMQX provides Command Line Interface, [HTTP API](./http-api.md#endpoint-data- import-and-export) and Dashboard’s visual interface (EMQX Enterprise) for data import and export functions. The data currently supported for import and export are as follows:

    • Rule engine configuration data (resources, rules)
    • Blacklist data
    • Dashboard user data
    • MQTT user data and ACL data added through the emqx-auth-mnesia plugin
    • MQTT user data and ACL data added through the emqx-auth-clientid plugin (exported from EMQX 4.2)
    • MQTT user data and ACL data added through the emqx-auth-username plugin (exported from EMQX 4.2)
    • Modules configuration
    • Configurations updated from HTTP API (or dashboard GUI)
    1. Export data. The file name format of the exported file is emqx-export-YYYY-MM-DD-HH-mm-SS.json, and the default export path is the data directory (Refer to )

    2. Save the exported file, and we save the exported file to the tmp directory here.

      1. $ cp /var/lib/emqx/emqx-export-2020-5-15-17-39-0.json /tmp
    3. Import data. The name of the imported file must be specified as an absolute path

      1. $ ./emqx_ctl data import /tmp/emqx-export-2020-5-15-17-39-0.json

    HTTP API

    1. Export data.

      1. $ curl -i --basic -u admin:public -X POST "http://localhost:8081/api/v4/data/export"
    2. Download data file

    3. Import data

      1. $ curl -i --basic -u admin:public -X POST "http://localhost:8081/api/v4/data/import" -d @/tmp/emqx-export-2020-9-4-10-24-16.json
      2. {"code":0}

      Steps 2 and 3 are suitable for migrating emqx on different devices