14 Tag-based Backup Management
Cloud and specifically AWS, is an environment based largely on automation. Since all the functionality is available via an API, scripts can be used to deploy and manage applications, servers, and complete environments. There are very popular tools available to help with configuring and deploying these environments, like Chef and Puppet.
N2WS allows configuring backup using automation tools by utilizing AWS tags. By tagging a resource (EC2 instance, EBS volume, EFS, DynamoDB, RDS instance, Aurora Cluster, or Redshift cluster), N2WS can be notified of what to do with this resource, and there is no need to use the UI. To tag Aurora clusters, tag one of the cluster’s DB instances, and N2WS will pick it up and back up the entire cluster.
Since tagging is a basic functionality of AWS, it can be easily performed via the API and scripts.
For Azure, the following options are not currently supported:
- Custom tag
- Exclude disk
- Application awareness
To automate backup management for a resource, you can add a tag to that resource named
cpm_backup).The tag is lower case with a space or an underscore. N2WS will identify this tag and parse its content. In this tag you will be able to specify whether to:
- Ignore the resource and remove it from all backup policies.
- Add the resource to a policy or list of policies.
- Create a new policy, based on an existing one (template), and then add the resource to it.
Following is a summary table of all
To add a resource (e.g., an EC2 instance) to an existing backup policy, all you need to do is to create the tag for this resource and specify the policy name. For example:
To add the resource to multiple policies all you need to do is to add a list of policy names, separated by spaces:
policy1 policy2 policy3
To create a new policy and to add the resource to it, add a new policy name with a name of an existing policy which will serve as a template (separated by semicolon):
tag value: new_policy1:existing_policy1
You can also add multiple policy name pairs to create additional policies or create a policy (or policies) and to add the resource to an existing policy or policies.
When a new policy is created out of a template, it will take the following properties from it:
- Number of generations
- DR configuration
- Script/agent configuration
- Retry configuration
It will not inherit any backup targets, so you can use a real working policy as a template or an empty one.
For Script definitions:
If backup scripts are defined for the template policy, the new one will keep that definition but will not initially have any actual scripts. You are responsible to create those scripts. Since the N2WS server is accessible via SSH you can automate script creation. In any case, since scripts are required, the backups will have a failure status and will send alerts, so you will not forget about the need to create new scripts.
For Windows instances with a backup agent configured:
If that was the configuration of the original policy, the new instance (assuming it is a Windows instance) will also be assigned as the policy agent. However, since it does not have an authentication key, and since the agent needs to be installed and configured on the instance, the backups will have a failure status. Setting the new authentication key and installing the agent needs to be made manually.
Auto Target Removal for the new policy will always be set to yes and alert, regardless of the setting of the template policy. The basic assumption is that a policy created by a tag will automatically remove resources that do not exist anymore, which is the equivalent as if their tag was deleted.
When adding an instance to a policy, or creating a new policy from template, you may make a few decisions about the instance:
- To create snapshots only for this instance.
- To create snapshots with an initial AMI.
- To schedule AMI creation only.
If this option is not set, N2WS will assume the default:
- Snapshots only for Linux.
- Snapshots with initial AMI for Windows instances by adding a backup option after the policy name. The backup option can be one of the following values:
For example, with an existing policy:
policy1#only-snaps, or for a new policy based on template and setting AMI creation:
For a Windows instance, you can also define backup with app-aware, i.e., a backup agent. It is used the same as the snapshots and AMI options.
- When adding the app-aware option, the agent is set to the default: VSS is enabled and backup scripts are disabled.
- app-aware-vss - Enable application consistent with VSS.
- app-aware-script - Enable application consistent without VSS.
- Additional configurations need to be made manually, and not with the tag.
You can also combine the backup options:
EFS can be configured by creating the
cpm_backuptag with the following values. In this case, N2WS will override the EFS configuration with the tag values:
cpm backup my_policy+vault=Default+exp_opt=D+exp_opt_val=1
N2WS will back up EFS to the default vault, and set its expiration date to 1 day.
N2WS can exclude a volume from an instance that is backed up on policy using the
#excludeadded to the end of the policy name value.
- Add a tag to an instance that you want to back up:
Key = cpm backup; Value = policy_name1 policy_name2
Key = cpm_backup; Value = policy_name1 policy_name2
- Add a tag to volumes that you would like to exclude from being backed up:
Key = cpm backup; Value = policy_name1#exclude policy_name2#exclude
key = cpm_backup; Value = policy_name1#exclude policy_name2#exclude
For example, if instance1 has 3 volumes and has a
cpm_backuptag with the value
policy1, adding the
cpm_backuptag with value
policy1#excludeto a volume will remove it from the policy.
The instance with the excluded volume(s) will be added automatically as a backup target to the policy, after running Scan Tag.
Custom Tags allow N2WS users to easily backup resources using any tag of their choice.
- You can define any number of Custom Tags on a Policy definition.
- Custom tags take precedence over
cpm_backuptags if both exist on a server.
- Define Custom Tags with the Names and Values to match the Tags of AWS Resources to add to the Policy.
- It is possible to match an AWS Resource Tag with an N2WS Tag Name or Value defined as a Prefix. For example, if the Tag Name ‘Department’ is defined as a Prefix, the following AWS resources that have a Tag Name starting with ‘Department’ will be added to the policy: ‘Department A’, ‘Departments’, and Department_3’.
To see which resources were added to backup, open the Tag Scan log (Show Log) and look for a Custom Tags match.
To create Custom Tags:
- 1.In the Policies tab, select a policy.
- 2.Select the More Options tab.
- 3.Turn on the Custom Tags toggle.
- 5.Define the Tag Name and Tag Value.
- 6.If the Name and/or Value is a prefix, select Name is Prefix .
Tag scanning can only be controlled by the admin/root user. When the scan is running, it will do so for all the users in the system but will only scan AWS accounts that have Scan Resources enabled. This setting is disabled by default. N2WS will automatically scan resources in all AWS regions.
- 1.In the General Settings tab, select the Tag Scan tab.
- 2.Select Scan Resources.
- 3.In the Tag Scan interval list, set the interval in hours for automatic scans.
- 5.Select Save.
- 6.To initiate a tag scan immediately, select Scan Now.
- 7.To view the Last Scan, select Show Log.
If you do want automated scans to run, keep scanning enabled and set the interval in hours between scans using the General Settings screen. You will also need to enable Scan Resources for the relevant N2WS Accounts. See section 3.1.2.
The following topics should help guide you when developing tags.
There are potential issues you should try to avoid when managing your backup via tags:
- The first is not to create contradictions between the tags content and manual configuration. If you tag a resource and it is added to a policy, and later you remove it from the policy manually, it may come back at the next tag scan. N2WS tries to warn you from such mistakes.
- Policy name changes can also affect tag scanning. If you rename a policy, the policy name in the tag can be wrong. When renaming a policy, correct any relevant tag values.
- When you open a policy that was created by a tag scan to edit it, you will see a message at the top of the dialog window: “* This policy was automatically added by tag scan”.
- If the same AWS account is added as multiple accounts in N2WS, the same tags can be scanned multiple times, and the behaviour can become unpredictable. N2W Software generally discourages this practice. It is better to define an account once, and then allow delegates (section 18.4) access to it. If you added the same AWS account multiple times (even for different users), make sure only one of the accounts in N2WS has Scan Resources enabled in N2WS.
Sometimes you need to understand what happened during a tag scan, especially if the tag scan did not behave as expected, such as a policy was not created. In the General Settings screen, you can view the log of the last tag scan and see what happened during this scan, as well as any other problems, such as a problem parsing the tag value, that were encountered. Also, if the daily summary is enabled, new scan results from the last day will be listed in the summary.
Ensure tag format is correct. Tips for ensuring correct tag formats are:
- When listing multiple policy names, make sure they are separated by spaces.
- When creating new policy, verify using a colon ‘
:’ and not a semi-colon ‘
;’. The syntax is
- Use a valid name for the new policy or it will not be created. An error message will be added to scan log.
- Use correct names for existing/template policies.
- Resource scanning order is NOT defined, so use policy names as existing/template only if you are sure that it exists in N2WS – defined manually or scanned previously.