# Scripts

## Overview

#### There are three types of backup scripts:

1. **Pre-backup** – executed <mark style="color:$danger;">before</mark> the backup starts. You can configure the backup to wait until this script finishes, which is mandatory for scenarios like **SQL** database backups.
2. **Post-snapshot** – executed <mark style="color:$danger;">after</mark> the backup snapshots have been created.
3. **Post-backup** – executed <mark style="color:$danger;">after</mark> the backup completes. For example, this script can be used to shut down the backed-up machine.

***

## Advantages

Using backup scripts can help automate the backup of resources that **Xopero ONE** cannot back up natively. **Xopero ONE** also provides features such as incremental and differential backups, deduplication, flexible scheduling, and detailed monitoring of backup copies.

***

## Enabling backup scripts

{% stepper %}
{% step %}
In the **Create backup plan** view, scroll to the bottom, click **Edit** next to **Advanced settings**, and then select **Backup scripts**.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FHZADKlOTE7gVnT9cIrQ6%2Fimage.png?alt=media&#x26;token=64aa04b8-cd8a-4514-9a7f-0b9d0686f116" alt="" width="536"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select the type of script you want to enable.

{% hint style="success" %}
You can enable multiple scripts at the same time.
{% endhint %}

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FbRCLEYrqw34pPWqQoJUc%2Fimage.png?alt=media&#x26;token=5cea35cc-354d-46a1-a70e-a1a993810ee8" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select the operating system (**Windows**, **Linux**, or **macOS**) and choose a [predefined script](#types_of_pre-defined_scripts) from the drop-down list.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FYQ4YJnnHIGBgOI7FTeva%2Fimage.png?alt=media&#x26;token=6b987bba-c1cd-49db-bee9-27eff5fe9c61" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
If you have selected a script, enable the **Wait for the script to continue the task** checkbox. This ensures that the backup task will wait until the script finishes. You can also configure a waiting interval and choose to fail the task if the script does not complete successfully.

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2Fp03VF7HmxRx6AjvaCB0G%2Fimage.png?alt=media&#x26;token=9b3b782e-d64a-49d9-8312-5edf687d3d87" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

***

## Predefined scripts <a href="#types_of_pre-defined_scripts" id="types_of_pre-defined_scripts"></a>

**Xopero ONE** provides a set of predefined scripts that can be used for common backup tasks. These scripts are ready to use and can be selected directly from the drop-down list when configuring your backup plan.

### <mark style="background-color:blue;">Pre-task scripts</mark>

{% hint style="warning" %}
The script is executed <mark style="color:$danger;">before the backup starts</mark>.
{% endhint %}

<div><figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FBZxhrkiSFYuj3I6Ppy0r%2Fimage.png?alt=media&#x26;token=f9cdeadd-4ca2-461a-bbae-29ce0d7037e4" alt=""><figcaption><p><em><strong>Windows OS</strong>.</em></p></figcaption></figure> <figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FsKagVuxvuDhSuEMozXGS%2Fimage.png?alt=media&#x26;token=b6d06638-f529-44fe-ac56-e18d2aef9dd1" alt=""><figcaption><p><em><strong>Linux</strong> and <strong>macOS</strong>.</em></p></figcaption></figure></div>

1. **SQL Server database backup** — protects a **Microsoft SQL** server database (**Windows** <mark style="color:$danger;">only</mark>).
2. **MySQL database backup** — protects a **MySQL** database (**Windows**, **Linux**, and **macOS**).
3. **PostgreSQL database backup** — protects a **PostgreSQL** database (**Windows**, **Linux**, and **macOS**).
4. **Oracle database backup** — protects an **Oracle** database environment (**Linux** and **macOS** <mark style="color:$danger;">only</mark>).
5. **Enter path\*** — allows you to run a custom script; simply type the path to your script to execute it using **Xopero ONE** (**Windows**, **Linux**, and **macOS**).

### <mark style="background-color:blue;">Post-snapshot scripts</mark>

{% hint style="warning" %}
The script is executed <mark style="color:$danger;">after the data snapshot has been completed</mark>.
{% endhint %}

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FnBrXj5Da8MZmjFSBQXF2%2Fimage.png?alt=media&#x26;token=7ff88517-84f9-4a65-a4aa-8c4739831b66" alt=""><figcaption><p><em><strong>Windows OS</strong>.</em></p></figcaption></figure>

1. **SQL Server database backup** — protects a **Microsoft SQL** server database.
2. **MySQL database backup** — protects a **MySQL** database.
3. **PostgreSQL database backup** — protects a **PostgreSQL** database.
4. **Enter path\*** — allows you to run a custom script; simply type the path to your script to execute it using **Xopero ONE**.

### <mark style="background-color:blue;">Post-task scripts</mark>

{% hint style="warning" %}
The script is executed <mark style="color:$danger;">after the backup is completed</mark>.
{% endhint %}

<figure><img src="https://319733277-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0CBTl43C3OO6ySL1DJ6k%2Fuploads%2FOo2WgF6H6QqOJZi2az5N%2Fimage.png?alt=media&#x26;token=d392d937-8b59-4e58-a075-d6eb9e7bc49a" alt=""><figcaption></figcaption></figure>

1. **Shutdown** — shuts down the device.
2. **Enter path\*** — allows you to run a custom script; simply type the path to your script to execute it using **Xopero ONE**.

{% hint style="danger" %}
**\***<mark style="color:$danger;">**WARNING!**</mark> If your backup plan includes multiple devices, the script <mark style="color:$danger;">**must**</mark> be located at the same path on all devices where you want it to run.
{% endhint %}

***

## Useful links and items

{% content-ref url="../../backup-and-recovery/workstations-and-servers/database-backup/microsoft-sql-database-backup" %}
[microsoft-sql-database-backup](https://helpcenter.xopero.com/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup/microsoft-sql-database-backup)
{% endcontent-ref %}

{% content-ref url="../../backup-and-recovery/workstations-and-servers/database-backup-recovery/restoring-mysql-database" %}
[restoring-mysql-database](https://helpcenter.xopero.com/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup-recovery/restoring-mysql-database)
{% endcontent-ref %}

{% content-ref url="../../backup-and-recovery/workstations-and-servers/database-backup/postgresql-database-backup" %}
[postgresql-database-backup](https://helpcenter.xopero.com/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup/postgresql-database-backup)
{% endcontent-ref %}

{% content-ref url="../../backup-and-recovery/workstations-and-servers/database-backup/oracle-database-backup" %}
[oracle-database-backup](https://helpcenter.xopero.com/xopero-one-en/backup-and-recovery/workstations-and-servers/database-backup/oracle-database-backup)
{% endcontent-ref %}
