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

Create a python script (gcp-filestore-backups) to perform backups and retention of filestore instances #4393

Closed
Tracked by #4391
yuvipanda opened this issue Jul 8, 2024 · 1 comment · Fixed by #4417
Assignees

Comments

@yuvipanda
Copy link
Member

yuvipanda commented Jul 8, 2024

Inputs

This script should take the following inputs (via commandline, parsed with argparse):

  1. Name of the filestore instance to create a backup of
  2. Name of the share inside the filestore instance to create a backup of (ours is called 'homes' I think)
  3. Region (and / or) zone the filestore instance is in
  4. Number of days to retain backups for

1-3 are based on what is needed to create backups and 4 is so we can figure out which backup to delete

Control Loop

We should design this script using some principles from kubernetes, so that it's easy to maintain and monitor. The fundamental piece is to think of this as a control loop. So the script should do the following:

  1. List all existing backups (gcloud filestore backups list --format json)
  2. Find all the backups that match the filestore and fileshare we care about (by filtering based on inputs 1,2, 3)
  3. If there has been no successful backup in the last 24h, create one (with gcloud filestore backups create). We pick 24h because these are 'daily' backups
  4. If there are backups older than now - input#4 (number of days), delete those backups.
  5. Sleep for a period of time (maybe 10min?), go back to step#1

This allows us to run this script multiple times, interrupt it, etc without too much worry. If there are extra backups, they will simply get deleted at the end of the retention period. If creating a backup fails, step (3) picks it up when running again.

Scope

This task is scoped to writing this script in such a way that any engineer with their local credentials will be able to run it from their computer after authenticating with gcloud and it would work. Deployment of this script and monitoring will be dealt with as further tasks under #4391

Client Library Use

Whoever does this task can either choose to parse the output of gcloud (with --format=json), or use the appropriate python client library. It's fairly minimal so the choice doesn't matter - do whatever feels comfortable to you, and don't spend too much time picking one or the other! If you have no opinions, pick using gcloud.

@yuvipanda yuvipanda changed the title Create a python script to perform backups and retention of filestore instances Create a python script (gcp-filestore-backups) to perform backups and retention of filestore instances Jul 8, 2024
@sgibson91
Copy link
Member

sgibson91 commented Jul 11, 2024

Where should this script live once it is written?

ETA: The answer may be helm-charts/images in the infrastructure repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants