> For the complete documentation index, see [llms.txt](https://helpcenter.xopero.com/xopero-one-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helpcenter.xopero.com/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup/mysql-database-backup.md).

# MySQL database backup

This article explains how to use backup scripts to create a MySQL database dump and include it in a backup plan.

#### In Xopero ONE, you can back up a variety of databases, including Oracle, Microsoft SQL, PostgreSQL, and MySQL.

***

## General information

The **MySQL** database backup process in **Xopero ONE** consists of two steps:

1. Creating a database dump using backup scripts.
2. Backing up the database dump.

The first step is performed through **Xopero ONE** using the **backup scripts** feature. The second step is a standard **file-level** or **image-level** backup executed directly by **Xopero ONE**.

By using the `mysqldump` tool, **Xopero ONE** supports all **MySQL** versions that are officially supported by **Oracle**.

***

## Backup configuration

{% hint style="info" %}
If a file-level backup plan has already been created and is running, you can skip directly to **step 6**.
{% endhint %}

{% stepper %}
{% step %}
Log in to [**XMS**](#user-content-fn-1)[^1], go to the **Backup** tab (**Plans** > **Backup**) and click the **+ Add plan** button in the top toolbar.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2Fd0F5f5WhfSR9uvIlOIH6%2Fimage.png?alt=media&amp;token=25d5ea87-098c-479d-b73f-70fd4e31c0a3" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select **Devices** from the platforms list.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2F4ZVwNgz1HAtRTmTxa3il%2Fimage.png?alt=media&amp;token=50f868db-0b47-41cc-8e02-d6649344a33f" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the next aside, select **one of the available** options and choose one or more devices for the plan to apply to (you can also select the plan to include all activated devices).

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FKVtZPjeVYiAB8kPTkb5H%2Fimage.png?alt=media&amp;token=ef86ef7e-39a3-4679-bbc2-e0e8301c22c1" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Define the name of the backup plan.
{% endstep %}

{% step %}
Configure your backup plan according to your needs (more information about the backup plan setup can be found in [File-level backup](/xopero-one-en/backup-and-recovery/workstations-and-servers/file-level-backup.md) and [Image-level backup](/xopero-one-en/backup-and-recovery/workstations-and-servers/image-level-backup.md) articles).
{% endstep %}

{% step %}
Go to the **Advanced settings** section and click **Edit** to customize additional options.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FRyfgoxkvn1BZkxzswOIX%2Fimage.png?alt=media&amp;token=6a3e613e-5e14-422b-8c24-52905e764352" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Scroll down to the **Backup scripts** section and click the **Pre-task script** toggle to turn it on.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FZlH6T78heqkgJMjgCtUv%2Fimage.png?alt=media&amp;token=0e970b7e-069e-4fa9-9c98-67f1200ab2ca" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select one of the scripts dedicated to backing up the **MySQL** database environment (**Windows** or **Linux**).

<div><figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FBVL9GqHatKxxGrwEXsGB%2Fimage.png?alt=media&amp;token=5c7ce0bf-e348-403d-aea8-8e5044ff9c08" alt=""><figcaption></figcaption></figure> <figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FKK2bVqYmov2ClJoJqcHO%2Fimage.png?alt=media&amp;token=38425d0d-eb24-4e36-9ec0-d4a42cf0a456" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
Type your database **username** into the **Database user** field.

{% hint style="warning" %}
It is strongly recommended to create a dedicated user specifically for database backup operations.
{% endhint %}

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2F5dx050hdE6VLZHsPr6VG%2Fimage.png?alt=media&amp;token=d9952760-afb3-4cb0-a674-46256f46c9f1" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Choose the user password by opening the **Password Manager**, where you can either add a new password or select an existing one.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FjC6HkM84mpVYFUSvp14s%2Fimage.png?alt=media&amp;token=0726abc4-f6a8-4224-857c-ea73752550fa" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Set up the script arguments — it should be entered in the **Script arguments** field as follows:

{% code title="Windows" overflow="wrap" %}

```
database output_dir mysqldump_dir port
```

{% endcode %}

{% code title="Linux" overflow="wrap" %}

```
database output_dir port
```

{% endcode %}

1. `database` — the name of the database. To include multiple databases in one backup plan, enter their names in the following format: `[database1 database2 database3]`. To back up all databases, use the `--all` parameter instead of specifying a database name.
2. `output_dir` — the directory where the database dump will be saved. This directory must also be selected in the **Data to protect** section when creating a backup plan.
3. `mysqldump_dir` — the path to the `mysqldump` utility.
4. `port` — an optional parameter. Enter the port number only if a non-standard port is used. The default port is **3306**.

{% hint style="danger" %}
When using the `mysqldump` utility on **Linux**, connections to the host named **'localhost'** are established through a socket file. If you do not specify a port in the configuration, the tool will connect correctly even when using a non-standard port. However, if you connect via **127.0.0.1**, specifying a non-standard port is required.
{% endhint %}

For example, to back up all databases from the **MySQL** environment, use the following arguments:

```
--all C:\MySQLBackup\ "C:\Program Files\MySQL\MySQL Server 8.0\bin"
```

If you want to back up only selected databases from the **MySQL** environment (for example, two out of seven), use the following arguments:

{% code overflow="wrap" %}

```
database1 database2 C:\MySQLBackup\ "C:\Program Files\MySQL\MySQL Server 8.0\bin"
```

{% endcode %}

{% hint style="warning" %}
**Important!** The `mysqldump` tool is part of the **MySQL** server and should be installed by default. If, for any reason, it is not available, you can download the **MySQL Utilities** package, which includes the `mysqldump` tool.
{% endhint %}
{% endstep %}

{% step %}
Enable the two additional options using the checkboxes:

1. **Wait for the script to continue the task** — the application will wait until the dump is ready.
2. **Fail the task if the script fails** — if the script fails, the system will notify you of the backup error.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2F3l8LsulpuY5ePaUxG7r1%2Fimage.png?alt=media&amp;token=ac5de632-48fc-4a30-a097-2f3065c0d5eb" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Double-check your settings and click **Save** to close the **Advanced settings** aside.
{% endstep %}

{% step %}
After completing the configuration, click the **Save** button. The protection plan will then automatically begin protecting your devices and databases according to the schedule you defined.

{% hint style="success" %}
You can also click **Save\&Run** button to immediately start the backup process, regardless of schedule.
{% endhint %}
{% endstep %}

{% step %}
That’s all you need to do to create the database dump — this file should now be included in the **Data to protect** section if you are performing a file-level backup (to back up only the database). Alternatively, you can run an image-level backup to protect the entire drive.
{% endstep %}
{% endstepper %}

***

## Useful links and items

{% embed url="<https://downloads.mysql.com/archives/utilities>" %}

[^1]: Xopero ONE Management Service
