> 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/postgresql-database-backup.md).

# PostgreSQL database backup

This article explains how to configure the PostgreSQL database environment in Xopero ONE.

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

***

## Prerequisites

To maintain data consistency, **Xopero** recommends using a dedicated backup type: **a file-based backup** with a pre-backup script for the **PostgreSQL** database.

{% hint style="success" %}
The pre-backup script can also be used to generate a database dump before performing a **disk-level backup**.
{% endhint %}

Database backup begins with a script that requests the database server to create a dump in a temporary directory. Once the dump is complete, **Xopero ONE** backs up the generated dump file.

**Xopero ONE** uses the `pg_dump` utility to back up **PostgreSQL** databases.

***

## Backup configuration

{% 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%2FNR1RTwfNKRDNXOy13RLV%2Fimage.png?alt=media&amp;token=654afc7d-649d-41b1-8bae-1200327f3f5c" 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%2FFO602wfQbkqX6jKDcl6m%2Fimage.png?alt=media&amp;token=7416fbfc-fb5d-4594-ba96-ab111f4b21fe" 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%2FOnTrPpQHPoX2m7OUAG8V%2Fimage.png?alt=media&amp;token=530163e4-dc0f-40e2-ab5e-7a373b9a9d58" 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%2Fha10dL2ZYQm7a4ovCy41%2Fimage.png?alt=media&amp;token=f8671a05-5fca-4229-9e6e-027f9e234429" 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%2FbshPK67etXFSg2GEAqqf%2Fimage.png?alt=media&amp;token=0ea5bb79-c304-4760-a5a6-489d0700ddbf" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select the script dedicated to backing up the **PostgreSQL** database environment.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FnMcYnzic8NdquDcqT7XV%2Fimage.png?alt=media&amp;token=faec952b-b63f-41c7-a9ac-7672e4ee7c43" alt=""><figcaption></figcaption></figure>
{% 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 %}
{% 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%2FUX2zy5NDWsDoWTLwiRCs%2Fimage.png?alt=media&amp;token=97adfc85-2867-4eef-801f-eb6baca38605" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FJ3G669RXQTaBoh987iw5%2Fimage.png?alt=media&amp;token=219c1399-ccd6-40b5-a777-8260faa86679" alt=""><figcaption></figcaption></figure>

```
database output_dir "pg_dump_dir" port_number
```

1. `database` — the name of the database to back up. A backup plan can target a single database or all databases. 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 created; this is also the folder that **Xopero ONE** will back up.
3. `pg_dump_dir` — the path to the `pg_dump` utility. This is required only for **PostgreSQL** databases hosted on **Windows**.
4. `port_number` — required only if your **PostgreSQL** server uses a non-standard port (**other than 5432**).

{% hint style="warning" %}
**Specifying the port is optional.** If no port is provided, the default port (**5432**) will be used. Use the `port_number` parameter only if your **PostgreSQL** server uses a non-standard port.
{% endhint %}
{% endstep %}

{% step %}
You can 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%2FLV85bZ0ekhZcnEgT4CZB%2Fimage.png?alt=media&amp;token=5411ed3c-f8fd-4905-bea2-af39551c0d80" 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.
{% endstep %}
{% endstepper %}

***

## Useful links and items

{% content-ref url="/pages/ZOPPjr4kLmSqnPfBTTTg" %}
[File-level backup recovery](/xopero-one-en/backup-and-recovery/workstations-and-servers/file-level-backup-recovery.md)
{% endcontent-ref %}

{% content-ref url="/pages/2kRF9D5o6i1a6aog9zXR" %}
[File-level backup](/xopero-one-en/backup-and-recovery/workstations-and-servers/file-level-backup.md)
{% endcontent-ref %}

{% content-ref url="/pages/fmxku9Sr43u0Fvr8JTt7" %}
[Restoring PostgreSQL database](/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup-recovery/restoring-postgresql-database.md)
{% endcontent-ref %}

[^1]: Xopero ONE Management Service
