Convert db download script to Python

This commit is contained in:
Ben Visness 2023-09-24 17:22:08 -05:00
parent ca46c23d31
commit 45b4928d83
3 changed files with 19 additions and 15 deletions

View File

@ -0,0 +1,18 @@
import boto3
# You must already have configured your "AWS" (DigitalOcean) credentials via the AWS CLI.
s3 = boto3.resource("s3")
bucket = s3.Bucket("hmn-backup")
for obj in bucket.objects.filter(Prefix="db"):
print(obj.key)
print()
print("Above is a list of all the available database backups.")
print("Enter the name of the one you would like to download (e.g. \"hmn_pg_dump_live_2023-09-24\"):")
filename = input()
s3 = boto3.client("s3")
s3.download_file("hmn-backup", f"db/{filename}", f"local/backups/{filename}")
print(f"Downloaded {filename} to local/backups.")

View File

@ -1,15 +0,0 @@
#!/bin/bash
set -euo pipefail
s3cmd ls s3://hmn-backup/db/
echo ""
echo "Above is a list of all the available database backups."
echo "Enter the name of the one you would like to download (e.g. \"hmn_pg_dump_live_2021-09-01\"):"
read filename
s3cmd get --force s3://hmn-backup/db/$filename ./local/backups/$filename
echo ""
echo "Downloaded $filename to local/backups."

1
local/requirements.txt Normal file
View File

@ -0,0 +1 @@
boto3