Skip to main content
Version: Next

Backup labeled namespaces

You can apply required labels to the namespaces using the CLI, filter the labeled namespaces with the web console and then backup all the labeled namespaces in a single click.

Prerequisites

  • The Stork version on your application cluster must be 23.9.1 to leverage namespace and resource label filters feature.

    Add Namespace label field gets disabled if the required Stork version is not deployed on the cluster and web console displays the minimum required Stork version.

Apply labels for namespaces

To apply labels for a namespace, from your CLI:

  1. Run the below command:

    kubectl label namespaces <name-of-namespace> <label_name_1> <label_name_2>………...<label_name_n>

    You can apply multiple unique labels (separated by a space) to a namespace in key-value format.

    note

    The key-value pair label format takes equals sign (=) as a separator.

  2. Run the below command to list the namespace(s) with the applied labels:

    kubectl get namespaces --show-labels
    note

    If you apply same labels to two different namespaces and list them with the applied labels, only first one gets listed.

  3. To remove the labels from the namespace:

    kubectl label namespaces <name-of-namespace> <key-of-the-label>-

Filter and backup labeled namespaces

To filter or view the namespaces with preset labels and then take a backup of the listed namespaces in the web console:

  1. From the home page, go to the left navigation pane and click Clusters icon.

  2. In the Clusters page, navigate to the required cluster.

  3. Go to Applications tab and then click NS tab.

  4. In the Search by backup label field, provide the required namespace label(s) that you applied through the CLI and then press Enter.

    Portworx Backup lists out and auto-selects all the namespaces with the preset labels. For more information on creating a backup with the listed namespaces, refer Create a backup.

note

You can search a namespace with preset labels either by providing only key or key-value string in the Search by backup label field. If you have applied multiple labels to a namespace, you can provide all the applied labels in the Search by backup label field with a comma separator (without space). User interface displays the namespace(s) that matches all the specified labels and auto-selects them to create a backup.

Example:

Consider an example where you create two namespaces ns1 and ns2 and apply the following labels to those two namespaces:

kubectl create ns ns1
kubectl label namespaces ns1 a=b
kubectl label namespaces ns1 c=d
kubectl create ns ns2
kubectl label namespaces ns2 c=d

When you search with the string a=b,c=d in the Add Namespace label field in the web console, search result applies AND operation to the provided labels and displays only ns1 and not both ns1 and ns2.

  1. Click Backup to back up all the namespaces with the preset label in a single-click.

Automate scheduled backups

If a namespace is yet to be created, you can still create a backup schedule for the future namespace with a label. Portworx Backup picks up the future namespace(s) with this label and automatically includes the namespace(s) as part of the schedule. In such a scenario, manual backup option gets disabled as no immediate backup is created.

If you have created a scheduled backup with one or few namespaces that have preset labels and add namespaces at a later point of time with the same label, scheduler auto-includes these namespaces to the scheduled backup.

To create a backup schedule when namespace is yet to be created:

  1. Type the required label in the Add Namespace label field.

  2. Click Backup. In the Create Backup window, enter the values for the required fields. Note that manual backup option Now is disabled.

  3. Click Create. For more information on how to create a backup, refer Create a backup.

    Portworx Backup creates a scheduled backup successfully without any namespace in it.

  4. After the backup is created, navigate to the Backups tab of the application cluster, click on the vertical ellipsis of newly created scheduled backup and choose Show details to view the backup details:


    You can view the backup details as per the below format:

Was this page helpful?