Skip to content

Commit 12fcb18

Browse files
authoredDec 1, 2021
feat(backup): enable WindowsVss Backup (#15934)
Closes #14803. Reference Pull Request : #14891 Lets you set the 'WindowsVss' option when you create a new backup plan like this: ```ts const plan = new BackupPlan(stack, 'Plan', { windowsVss: true, }); ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 534babd commit 12fcb18

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
 

‎packages/@aws-cdk/aws-backup/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ const plan = backup.BackupPlan.daily35DayRetention(this, 'Plan', myVault); // Us
8282
plan.addRule(backup.BackupPlanRule.monthly1Year(otherVault)); // Use `otherVault` for this specific rule
8383
```
8484

85+
You can [backup](https://docs.aws.amazon.com/aws-backup/latest/devguide/windows-backups.html)
86+
VSS-enabled Windows applications running on Amazon EC2 instances by setting the `windowsVss`
87+
parameter to `true`. If the application has VSS writer registered with Windows VSS,
88+
then AWS Backup creates a snapshot that will be consistent for that application.
89+
90+
```ts
91+
const plan = new backup.BackupPlan(this, 'Plan', {
92+
windowsVss: true,
93+
});
94+
```
95+
8596
## Backup vault
8697

8798
In AWS Backup, a *backup vault* is a container that you organize your backups in. You can use backup

‎packages/@aws-cdk/aws-backup/lib/plan.ts

+22
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ export interface BackupPlanProps {
4343
* @default - use `addRule()` to add rules
4444
*/
4545
readonly backupPlanRules?: BackupPlanRule[];
46+
47+
/**
48+
* Enable Windows VSS backup.
49+
*
50+
* @see https://docs.aws.amazon.com/aws-backup/latest/devguide/windows-backups.html
51+
*
52+
* @default false
53+
*/
54+
readonly windowsVss?: boolean;
4655
}
4756

4857
/**
@@ -124,6 +133,7 @@ export class BackupPlan extends Resource implements IBackupPlan {
124133

125134
const plan = new CfnBackupPlan(this, 'Resource', {
126135
backupPlan: {
136+
advancedBackupSettings: this.advancedBackupSettings(props),
127137
backupPlanName: props.backupPlanName || id,
128138
backupPlanRule: Lazy.any({ produce: () => this.rules }, { omitEmptyArray: true }),
129139
},
@@ -140,6 +150,18 @@ export class BackupPlan extends Resource implements IBackupPlan {
140150
}
141151
}
142152

153+
private advancedBackupSettings(props: BackupPlanProps) {
154+
if (!props.windowsVss) {
155+
return undefined;
156+
}
157+
return [{
158+
backupOptions: {
159+
WindowsVSS: 'enabled',
160+
},
161+
resourceType: 'EC2',
162+
}];
163+
}
164+
143165
/**
144166
* Adds a rule to a plan
145167
*

‎packages/@aws-cdk/aws-backup/test/plan.test.ts

+30
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ test('create a plan and add rules', () => {
7070
});
7171
});
7272

73+
test('create a plan and add rules - add BackupPlan.AdvancedBackupSettings.BackupOptions', () => {
74+
const vault = new BackupVault(stack, 'Vault');
75+
const otherVault = new BackupVault(stack, 'OtherVault');
76+
77+
// WHEN
78+
const plan = new BackupPlan(stack, 'Plan', {
79+
windowsVss: true,
80+
backupVault: vault,
81+
backupPlanRules: [
82+
new BackupPlanRule({
83+
completionWindow: Duration.hours(2),
84+
startWindow: Duration.hours(1),
85+
scheduleExpression: events.Schedule.cron({
86+
day: '15',
87+
hour: '3',
88+
minute: '30',
89+
}),
90+
moveToColdStorageAfter: Duration.days(30),
91+
}),
92+
],
93+
});
94+
plan.addRule(BackupPlanRule.monthly5Year(otherVault));
95+
96+
Template.fromStack(stack).hasResourceProperties('AWS::Backup::BackupPlan', {
97+
BackupPlan: {
98+
AdvancedBackupSettings: [{ BackupOptions: { WindowsVSS: 'enabled' }, ResourceType: 'EC2' }],
99+
},
100+
});
101+
});
102+
73103
test('daily35DayRetention', () => {
74104
// WHEN
75105
BackupPlan.daily35DayRetention(stack, 'D35');

0 commit comments

Comments
 (0)
Please sign in to comment.