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

Regularly delete old backups #4196

Open
inglesp opened this issue Jul 24, 2023 · 0 comments
Open

Regularly delete old backups #4196

inglesp opened this issue Jul 24, 2023 · 0 comments

Comments

@inglesp
Copy link
Contributor

inglesp commented Jul 24, 2023

For the last five years we've been backing up the postgres database to Google Cloud Storage daily. Each backup is 30GB, and the total cost was creeping up.

After discussion I've cleared out all backups except those taken on the first of the month:

import re
from google.cloud.storage import Client

c = Client("ebmdatalab")
for b in c.list_blobs("ebmdatalab_db_backups", prefix="prescribing"):
  if re.search("_01\.sql\.gz$", b.name):
    continue
  print(b.name)
  b.delete()

We should run a job to do this regularly.

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

No branches or pull requests

2 participants