Manage snapshot policies using the CLI
Manage snapshot policies using the CLI, ensuring efficient data protection and disaster recovery.
Overview
Creating policies using the CLI involves leveraging policy templates for efficient and consistent policy management that align with organizational requirements.
Process overview:
Export an existing policy to a template: The first step in creating a policy template is exporting an existing policy. If this is your first time, you can use the
sys-default
policy (json file), a predefined system policy that serves as a baseline. Thesys-default
policy is not editable, so it is ideal for use as an initial template.Edit the exported policy template: After exporting the
sys-default
policy, you can modify the exported json file to suit your specific requirements. This customization allows you to create tailored templates for different groups of policies, streamlining policy creation for various scenarios.Create a policy from a policy template: Create a new policy from the desired policy template and customize it further as needed to address specific use cases. This approach provides flexibility while ensuring consistency across policies derived from the same template.
Attach filesystems to a snapshot policy: Attach the relevant filesystems to the snapshot policy to ensure that the policy governs the creation, management, and retention of snapshots for these specific filesystems. This step links the policy to the filesystems, enabling consistent enforcement of snapshot rules and schedules.
After understanding the workflow for creating policies using the CLI, you can use the following commands to manage snapshot policies:
List snapshot policies
Show snapshot policy details
Export snapshot policy
Create snapshot policy
Attach filesystems to a snapshot policy
Detach filesystems from a snapshot policy
Update snapshot policy
Delete snapshot policy
List snapshot policies
Command: weka fs protection snapshot-policy list
This command displays a list of all existing snapshot policies in the system. The output includes details such as the policy ID, name, enabled status, description, and any filesystems the policy is attached to.
Show snapshot policy details
Command: weka fs protection snapshot-policy show
This command displays the configuration of a snapshot policy in JSON format. It provides a detailed representation of the policy, including schedules (hourly, daily, weekly, monthly, and periodic), retention settings, associated filesystems, and whether specific features are enabled.
JSON overview
Schedules: Defines hourly, daily, weekly, monthly, and periodic snapshot schedules, including time, days, and upload settings.
Retention: Specifies the number of snapshots to retain for each schedule type.
Filesystems: Lists the filesystems attached to the policy.
General settings: Includes the policy name, description, and enable/disable status.
Parameters
name
*
Policy name
Export snapshot policy
Command: weka fs protection snapshot-policy export
This command exports the configuration of an existing snapshot policy to a template file. Use the sys-default
policy to export the cluster's default configuration as a baseline for creating customized policy templates.
Parameters
name
*
The snapshot policy to export.
path
*
The path to the directory to save the export policy file.
Customize the policy template
To customize a policy template, follow these steps:
Open the exported template: Use a text editor, such as
vi
, to open the policy template file that you exported from thesys-default
template or an existing snapshot policy.Modify configuration details: Edit the template to customize the policy's configuration, such as schedules, retention rules, or other relevant settings, to meet your specific requirements.
Reuse the customized template: Save your changes. The modified template can now be used to create new policies tailored to your needs.
Create snapshot policy
Command: weka fs protection snapshot-policy create
This command creates a new snapshot policy based on a specified template file. Provide the policy name, template file path, and optional parameters such as a description or enabled status.
Parameters
name
*
The snapshot policy name. Up to 12 alphanumeric characters, hyphens (-), underscores (_), and periods (.)
path
*
The path to the snapshot policy file. It must be in JSON format.
description
Policy description. Up to 128 characters.
enabled
Set snapshot policy status.
Possible values: true
or false
true
Attach filesystems to a snapshot policy
Command: weka fs protection snapshot-policy attach
This command attaches existing filesystems to a snapshot policy. Before proceeding, ensure each filesystem is attached to an object store.
Parameters
name
*
The snapshot policy name.
filesystems
...
A list of filesystems you want to attach to the policy.
Detach filesystems from a snapshot policy
Command: weka fs protection snapshot-policy detach
This command detaches the specified filesystems from the snapshot policy. To remove waiting tasks associated with the filesystems, add the --remove-waiting-tasks
option.
Parameters
name
*
The snapshot policy name
filesystems
...
A list of filesystems you want to detach from the policy
remove-waiting-tasks
Allow to delete all waiting tasks corresponding to the filesystems.
Update a snapshot policy
Command: weka fs protection snapshot-policy update
This command updates an existing snapshot policy. You can modify its name, description, policy parameters or enabled status.
Parameters
name
*
Existing snapshot policy name.
new-name
New policy name. Up to 12 alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description
New policy description. Up to 128 characters.
path
The path to the new or modified snapshot policy file. It must be in JSON format.
enabled
Set snapshot policy status.
Possible values: true
or false
Delete a snapshot policy
Command: weka fs protection snapshot-policy delete <name>
This command deletes the specified snapshot policy from the system. Ensure that no filesystems are attached to the policy before proceeding with the deletion.
Parameters
name
*
Existing snapshot policy name.
Last updated