Skip to main content
Version: 2.6

Backup labeled namespaces

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

Prerequisites

  • The Stork version on your application cluster must be 23.9.1 and above for namespace and resource label filters.

    Add Namespace label field gets disabled if the required Stork version is not deployed on the cluster. In addition, UI displays the following error message:
    Stork error

Apply labels for namespaces

To apply labels for a namespace:

  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.

  1. 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.

  2. 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 user interface:

  1. From the home page, navigate to the cluster where your namespace resides.

  2. In the Add Namespace label field, provide the required namespace label(s) that you applied through the CLI and then press Enter.

    Namespace resource labels

    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.

    Filtered namespaces

    note

    You can search a namespace with preset labels either by providing only key or key-value string in the Add Namespace label field. If you have applied multiple labels to a namespace, you can provide all the applied labels in the Add Namespace 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 user interface, 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.

    Future namespace

  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:

Was this page helpful?