Skip to content

Proposed fix for issue #5 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lambda/backuplambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,22 @@ def snapshot_resource(self, resource, description, tags):
date = datetime.today().strftime('%d-%m-%Y-%H-%M-%S')
snapshot_id = self.period+'-'+self.resolve_backupable_id(resource)+"-"+date+"-"+self.date_suffix

current_snap = self.conn.create_db_snapshot(DBInstanceIdentifier=self.resolve_backupable_id(resource),
DBSnapshotIdentifier=snapshot_id,
Tags=aws_tagset)
if is_cluster(resource):
Copy link
Contributor

@stevemac007 stevemac007 Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.is_cluster(resource):

current_snap = self.conn.create_db_cluster_snapshot(
DBClusterIdentifier=self.resolve_backupable_id(resource),
DBClusterSnapshotIdentifier=snapshot_id,
Tags=aws_tagset)
else:
current_snap = self.conn.create_db_snapshot(
DBInstanceIdentifier=self.resolve_backupable_id(resource),
DBSnapshotIdentifier=snapshot_id,
Tags=aws_tagset)

def is_cluster(self, resource):
try:
return resource['DBClusterIdentifier'] is not None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do this as

return 'DBClusterIdentifier' in resource

And not need the try except.

except:
return False

def list_snapshots_for_resource(self, resource):
snapshots = self.conn.describe_db_snapshots(DBInstanceIdentifier=self.resolve_backupable_id(resource),
Expand Down