> For the complete documentation index, see [llms.txt](https://docs.enginsight.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enginsight.com/docs/knowledge-base/english/database/how-do-i-create-a-backup-of-my-enginsight-instance.md).

# How do I create a backup of my Enginsight instance?

Enginsight uses MongoDB as its database. To create a backup of your Enginsight database, you need to perform a *MongoDB dump*. There are several ways to do this, which we describe below.

***

## Backup Process

{% stepper %}
{% step %}

### Stop the Enginsight Application Server

{% hint style="danger" %}
**Please note**: This step is *mandatory* before making any changes to the database!
{% endhint %}

1. Log in to the Enginsight Application Server and navigate to the Enginsight installation directory using the following command:

```
cd /opt/enginsight/enterprise
```

2. Now stop the Application Server using the following command:

```
sudo docker-compose down
```

{% endstep %}

{% step %}

### Create the database backup

Log in to the Database Server and run the MongoDB dump command that applies to your setup:

* [Full dump with current date](#full-dump-with-current-date)
* [Dump via an encrypted connection including authentication](#dump-via-an-encrypted-connection-including-authentication)
  {% endstep %}

{% step %}

### Restart the Application Server

1. Go back to the Application Server and navigate to the Enginsight installation directory using the following command:

```
cd /opt/enginsight/enterprise
```

2. Run the Application Server setup script again using the following command to restart the Application Server, and confirm all prompts by pressing **Enter**:

```
sudo ./setup.sh
```

{% endstep %}
{% endstepper %}

***

## Commands for Different Backup Options

Here you can find the different backup options for your Enginsight instance:

### Full Dump With Current Date

The following dump option saves the `enginsight` database to a directory named with the current date:

<pre><code>mongodump \
<strong>    --host "rs0/&#x3C;DatabaseServerIPAddress>:27017" \
</strong>    --db enginsight \
<strong>    --out /&#x3C;BackupDirectoryPath>/$(date +%F)
</strong></code></pre>

{% hint style="info" %}
Remember to replace `<DatabaseServerIPAddress>` with the corresponding IP address and `<BackupDirectoryPath>` with the file path to your backup file. The date is output in YYYY-MM-DD format.
{% endhint %}

### Dump via an Encrypted Connection Including Authentication

The following dump option saves the `enginsight` database to a directory named with the current date via a connection secured with SSL/TLS. This is required if SSL/TLS encryption is configured for the database. Authentication via username and password (role-based access control; RBAC) is also performed.

<pre><code>mongodump \
<strong>    --host "rs0/&#x3C;DatabaseServerIPAddress>:27017" \
</strong>    --username "mongoDefaultUser" \
    --password "$(sudo cat /etc/enginsight/mongoDefaultUserPassword)" \
    --ssl \
    --sslCAFile /etc/enginsight/ssl/mongodbCA.crt \
    --sslPEMKeyFile /etc/enginsight/ssl/mongodb.pem \
    --db enginsight \
<strong>    --out /&#x3C;BackupDirectoryPath>/$(date +%F)
</strong></code></pre>

{% hint style="info" %}
Remember to replace the following placeholders in `<>` accordingly:

* `<DatabaseServerIPAddress>`
* `<BackupDirectoryPath>`
  {% endhint %}

***

## Restoring a Backup

{% hint style="danger" %}
**Please note**: The Enginsight Application Server must also be stopped before restoring a MongoDB dump!
{% endhint %}

To restore a backup, you have the following options:

### Restore Without an Encrypted Connection

<pre><code>mongorestore \
<strong>    --host "rs0/&#x3C;DatabaseServerIPAddress>:27017" \
</strong>    --db enginsight \
<strong>    /&#x3C;BackupDirectoryPath>/&#x3C;BackupDate>/enginsight
</strong></code></pre>

{% hint style="info" %}
Remember to replace the following placeholders in `<>` accordingly:

* `<DatabaseServerIPAddress>`
* `<BackupDirectoryPath>`
* `<BackupDate>` : The date must be specified in YYYY-MM-DD format.
  {% endhint %}

### Restore via an Encrypted Connection Including Authentication

This option is required if SSL/TLS encryption is configured for the database. Authentication via username and password (role-based access control; RBAC) is also performed.

<pre><code>mongorestore \
<strong>    --host "rs0/&#x3C;DatabaseServerIPAddress>:27017" \
</strong>    --username "mongoDefaultUser" \
    --password "$(sudo cat /etc/enginsight/mongoDefaultUserPassword)" \
    --ssl \
    --sslCAFile /etc/enginsight/ssl/mongodbCA.crt \
    --sslPEMKeyFile /etc/enginsight/ssl/mongodb.pem \
    --db enginsight \
<strong>    /&#x3C;BackupDirectoryPath>/&#x3C;BackupDate>/enginsight
</strong></code></pre>

{% hint style="info" %}
Remember to replace the following placeholders in `<>` accordingly:

* `<DatabaseServerIPAddress>`
* `<BackupDirectoryPath>`
* `<BackupDate>` : The date must be specified in YYYY-MM-DD format.
  {% endhint %}

***
