diff --git a/local/download_database.py b/local/download_database.py new file mode 100644 index 0000000..a447f2d --- /dev/null +++ b/local/download_database.py @@ -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.") diff --git a/local/download_database.sh b/local/download_database.sh deleted file mode 100755 index ff1731d..0000000 --- a/local/download_database.sh +++ /dev/null @@ -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." diff --git a/local/requirements.txt b/local/requirements.txt new file mode 100644 index 0000000..23d75a2 --- /dev/null +++ b/local/requirements.txt @@ -0,0 +1 @@ +boto3