Skip to main content
Version: 2.8

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 rule for backup, execute the following steps:

  1. Login and access Portworx Backup home page.

  2. At the bottom of left navigation pane, click Settings > Rules.

  3. In the Backup Rules, click on the + icon or Add new:

  4. Build your rule by populating the following fields:

    • Rule Name: enter a descriptive name for your rule

    • 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

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

    • Container (Optional): enter the optional name of the container to which Portworx Backup will apply the rule

    • Action: enter any commands you want to execute when the rule is triggered

    • 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)

    • 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).

  5. (Optional): Select the + Add icon to add more sub-rules:

  6. Click Add to create the rule:

Once you have created a rule, you can associate it with a backup.

Was this page helpful?