Skip to main content
Version: 3.0

Add Backup Rules

Applicable to both Classic and Federated modes

Backup rules are database-dependent scripts executed on containers before or after the backup operation to ensure application-consistent backups. Rules executed before and after the backup operation are called pre-exec and post-exec rules respectively. These rules are predominantly used to either freeze or unfreeze input/output operations of applications to facilitate Portworx Backup to take consistent backups.

In the backend, Portworx Backup initiates a Pod (cmdexecutor) to execute the required rules on the container based on labels applied to the Deployments. If you have applied the same label to a set of Deployments, the cmdexecutor Pod selects all of them and applies the defined rule or set of rules.

Some applications may only require freeze or pre-exec rules. If you want to add multiple instructions to a rule, you can add sub-rules. For example, while backing up an Elasticsearch application, you can add a sub-rule for a health check along with the freeze operation.

To create a pre-exec rule for backup:

  1. Log in and access the Portworx Backup home page.

  2. In the left navigation pane, click Rules.

  3. In the Backup Rules page, click Create Rules:

  4. In the Create Rules page, build your rule by populating the following fields:

    1. Rule Name: Enter a descriptive name for your rule.

    2. Pod selector: Enter any label selectors based on your Pod’s labels. For example, app=postgres uses the app label to select Pods running postgres. Use any of the equality-based selector operators. Make sure there is no space before or after the = sign.

      For more information on labeling guidelines, refer to labeling guidelines.

    3. Container (Optional): Enter the name of the container to which Portworx Backup applies the rule.

    4. Action: Enter any commands you want to execute when the rule is triggered.

    5. Background: Enable this if you want the rule to run in the background. The rule runs as a background process and can be used to back up crash-consistent applications (for example, MySQL).

    6. Run in single pod: Run this rule in a single Pod. The Kubernetes scheduler chooses the Pod and can be used to take a backup of lead-based applications (for example, MongoDB).

    7. + icon: Click this icon if you need to add more than one action to the same application.

  5. (Optional): Select the + Add icon to add more sub-rules if you have more than one container for the chosen application (Pod selector) or if you need to apply rules for more than one application at the same time.

  6. Click Add to create the pre-exec rule:

After you create this pre-exec rule, the rule is listed in the Backup Rules page. You can later associate this rule with a backup. The pre-exec rule is applied before the backup is created.

Similarly, you can create post-exec rules for the required applications. The post-exec rule is applied after the backup is created.

Related topic