> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/xsoar-6-administrator-guide/6.14/onboard-cortex-xsoar/disaster-recovery-and-live-backup/restore-the-database.md).

# Restore the Database

Cortex XSOAR automatically backs up the database. If the database becomes corrupted or you need to revert to an earlier version of your data, you can restore a database backup.

{% hint style="info" %}

### Note

Any Cortex XSOAR service that uses the Elasticsearch database does not run automatic backups. To back up or restore the contents of your Elasticsearch database, follow the instructions for [Disaster Recovery for Elasticsearch](/xsoar-6-administrator-guide/6.14/onboard-cortex-xsoar/elasticsearch/disaster-recovery-for-elasticsearch.md).
{% endhint %}

1. Log out all users from Cortex XSOAR.
2. Stop the service.

   **`sudo service demisto stop`**
3. Delete the contents of the database directory.

   By default, the database directory is **`/var/lib/demisto/data`**.
4. Copy the backup file to the database location.
5. Extract the **`.gzip`** backup file using **` tar -xzf`` `` `*****`<file-name>`***.

   When you run the command, new sub-folders are created (where you ran the command) with the **`db`** files inside. If you use the default path, the files are in the **`var`** folder. For example, the following files are generated:

   ```programlisting
   root@myhost:/var/lib/demisto/backup# tar -xzf daily_29_Jun_2021__0738.tar.gz
   root@myhost:/var/lib/demisto/backup# cd var/lib/demisto/backup/daily_29_Jun_2021__0738
   root@myhost:/var/lib/demisto/backup/var/lib/demisto/backup/daily_29_Jun_2021__0738# ls
   demisto.db  demisto_062021.db
   ```
6. **Automatic Backup**

   * Move the **`demisto_XXXXX.db`** files to the **`partitionsData`** folder.
   * Keep the **`demisto.db`** file in the **`/data`** parent folder.

   **Manual Backup**

   You do not need to move the files, as the required **`_XXXXX.db`** files are already in the **`partitionsData`** folder
7. The following directories need to be restored manually:
   * `/var/lib/demisto/artifacts`
   * `/var/lib/demisto/attachments`
   * `/var/lib/demisto/images`
   * `/var/lib/demisto/d2_server.key`
   * `/var/lib/demisto/tools`
   * `/var/lib/demisto/versionControlRepo`
   * `/usr/local/demisto`
   * `/etc/demisto.conf`
8. Restart the server and log in to Cortex XSOAR.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/xsoar-6-administrator-guide/6.14/onboard-cortex-xsoar/disaster-recovery-and-live-backup/restore-the-database.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
