Skip to content

Commit 6a427cb

Browse files
committed
WIP: continue adding backup schedule lifecycle rules
1 parent 4a04d4f commit 6a427cb

1 file changed

Lines changed: 37 additions & 10 deletions

File tree

lib/tasks/shf_aws.rake

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,55 @@ namespace :shf do
136136
# This simplifies our rake task syntax in the terminal.
137137
aws_s3 = Backup.s3_backup_resource
138138
aws_client = aws_s3.client
139-
aws_s3_backup_bucket_name = "shf-test-backups" # Remember to revert to production bucket
139+
aws_s3_backup_bucket_name = Backup.s3_backup_bucket # Remember to revert to production bucket
140140
aws_s3_backup_bucket_full_prefix = Backup.s3_backup_bucket_full_prefix
141-
142-
storage_rules = [{days: 90, storage_class: 'GLACIER'}, {days: 450, storage_class: 'DEEP_ARCHIVE'}]
141+
# binding.pry
143142

144143
ActivityLogger.open(LogfileNamer.name_for(LOGFILENAME), LOG_FACILITY, 'Add bucket lifecycle configuration') do |log|
145144
aws_client.put_bucket_lifecycle_configuration({
146145
bucket: aws_s3_backup_bucket_name,
147146
lifecycle_configuration: {
148147
rules: [
149148
{
150-
expiration: {
151-
days: 3650
152-
},
153-
id: "Transition objects to GLACIER after 90 days then move them to DEEP_ARCHIVE after 450 days",
149+
id: "Daily backup schedule - Transition objects to STANDARD_IA for 60 days",
154150
filter: {
155151
prefix: aws_s3_backup_bucket_full_prefix
156152
},
157153
status: 'Enabled',
158-
transitions: storage_rules,
159-
abort_incomplete_multipart_upload: {
160-
days_after_initiation: 10 # Remember to change this based on PR reply.
154+
transitions: [
155+
{
156+
days: 60,
157+
storage_class: 'STANDARD_IA'
158+
}
159+
]
160+
},
161+
{
162+
id: "Monthly backup schedule - Transition objects to GLACIER for 60 days",
163+
filter: {
164+
prefix: "01/"
165+
},
166+
status: 'Enabled',
167+
transitions: [
168+
{
169+
days: 365,
170+
storage_class: 'GLACIER'
171+
}
172+
]
173+
},
174+
{
175+
id: "Yearly backup schedule - Transition objects to DEEP_ARCHIVE for 365 days",
176+
filter: {
177+
prefix: "01/01/"
178+
},
179+
status: 'Enabled',
180+
transitions: [
181+
{
182+
days: 365,
183+
storage_class: 'DEEP_ARCHIVE'
184+
}
185+
],
186+
expiration: {
187+
days: 3650
161188
}
162189
}
163190
]

0 commit comments

Comments
 (0)