Skip to content
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

bigtable-backup: list backups just before starting deletion of wanted backups #1128

Merged
Merged
Changes from all commits
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
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