Convert db download script to Python
This commit is contained in:
parent
ca46c23d31
commit
45b4928d83
|
@ -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.")
|
|
@ -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."
|
|
@ -0,0 +1 @@
|
|||
boto3
|
Loading…
Reference in New Issue