Skip to content

Commit

Permalink
list backups just before starting deletion of wanted backups
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepsukhani committed Oct 9, 2019
1 parent b835e20 commit b75965e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tools/bigtable-backup/bigtable-backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ def ensure_backups(args):

num_backups_deleted = 0

# list backups again to verify them below
backups = list_backups(args.destination_path)

print("Checking whether all the backups are created after their period is over and deleting old unwanted backups")
print("Checking whether all the backups are created after their period is over")
for table_id, timestamps in backups.items():
table_number = int(table_id.rsplit("_", 1)[-1])
last_timestamp_from_table_number = find_last_timestamp_from_table_number(table_number,
Expand All @@ -76,6 +73,13 @@ def ensure_backups(args):
if last_timestamp_from_table_number > timestamps[-1]:
create_backup(table_id, args)

# list backups again to consider for deletion of unwanted backups since new backups might have been created above
backups = list_backups(args.destination_path)

print("Deleting old unwanted backups")
for table_id, timestamps in backups.items():
table_number = int(table_id.rsplit("_", 1)[-1])

# Retain only most recent backup for non active table
if table_number != active_table_number and len(timestamps) > 1:
for timestamp in timestamps[:-1]:
Expand Down

0 comments on commit b75965e

Please sign in to comment.