Skip to main content
Version: 2.9

Add Backup Rules

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 same label to a set of deployments, the cmdexecutor pod selects all of them and then apply 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 freeze operation.

To create a pre-exec rule for backup, execute the following steps:

  1. Login and access 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 that there is no space before or after = sign here.

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

    3. Container (Optional): enter the optional name of the container to which Portworx Backup will apply 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. Rule runs as a background process, can be used to back up crash consistent applications. (For example, mySQL)

    6. Run in single pod: run this rule in a single pod. Kubernetes scheduler chooses the pod here and can be used to take a backup of your elective lead based applications (for example, mongoDB).

    7. + icon: click on this icon if you have 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 you have to apply rules for more than one application in one go.

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

Once you have created this pre-exec rule, the rule gets listed in the Backup Rules page. You can later associate this rule with a backup. The pre-exec rule gets applied before creation of backup.

Similarly you can create post-exec rules for the required applications. Post-exec rule gets applied after the creation of backup.

Related topic