- Newest
- Most votes
- Most comments
The following code is called (via Puppet) with a single parameter (the name of the host that is having it's lifecycle created) and stdout posted to a file
#!/usr/bin/python2 import sys from boto.s3.connection import S3Connection from boto.s3.lifecycle import Lifecycle, Expiration, Transition, Rule
name = sys.argv[1]
conn = S3Connection() bucket = conn.get_bucket('penmanconsulting-server-backups') lifecycle = bucket.get_lifecycle_config()
Eday = Expiration( days=7 ) Eweek = Expiration( days=28 ) Emonth = Expiration( days=365 ) Tmonth = Transition( days=1, storage_class='GLACIER' ) Tyear = Transition( days=1, storage_class='GLACIER' )
lifecycle.append( Rule( name+'-daily', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Eday )) lifecycle.append( Rule( name+'-weekly', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Eweek )) lifecycle.append( Rule( name+'-monthly', '{host}/monthly/'.format( host=name ), 'Enabled', expiration=Emonth, transition=Tmonth )) lifecycle.append( Rule( name+'-yearly', '{host}/yearly/'.format( host=name ), 'Enabled', transition=Tyear ))
not conditional, so that lifecycle rules can be updated.
bucket.configure_lifecycle(lifecycle) print "Lifecycle applied."
print "-----" print lifecycle.to_xml()
Relevant content
- asked 9 months ago
- asked 2 months ago
- asked 2 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago