# Backup and Restore
EMQX adopts a distributed storage schema and also introduces a cluster transfer feature to ensure the system's high availability.
This chapter will discuss how to backup your operating data and configuration files to prevent data losses in case of system malfunctions.
# Configuratation Files
When EMQX is deployed with a deployment tool, the configuration center, or Git, these configurations will be automatically backed up, and no manual backup is needed.
However, for the manually configured items, it is recommended to run a periodic backup. The configuration files may locate at:
/etc/emqx
: when installed from RPM or DEB packages/opt/emqx/etc
: when running in docker container/path/to/install/dir/etc
: when directly extracted from zip package.
Besides the etc
directory, there are also some configuration-related files in the data
directory. For details, see Configuration file.
# Built-in Database
By default, EMQX will use the built-in database for data storage, therefore you can back up the mnesia
folder under data
.
Based on the installation mode, the file path could be:
/var/lib/emqx/data
: when installed from RPM or DEB packages/opt/emqx/data
: when running in docker container./data
: when directly extracted from zip package.
You can also specify the data
directory location via node.data_dir
or the EMQX_NODE__DATA_DIR
environment variable.
# Persisted Sessions
Before EMQX 5.0, persistent sessions were stored in memory, and for the EMQX enterprise version, they are stored in an external database, so you cannot back up persistent sessions in EMQX.
# Data Restore
To restore the configuration file, you only need to place the backed-up configuration files and data in the corresponding directory before starting EMQX.