added backup script

This commit is contained in:
Yannic Kilcher
2023-01-17 12:21:16 +01:00
parent ca9af52c51
commit 4379aadd87
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -7,3 +7,5 @@ RUN apt-get update && apt-get install -y unzip curl && rm -rf /var/lib/apt/lists
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip -q awscliv2.zip
RUN ./aws/install
COPY ./backup_pg_to_s3.sh .
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
set -x
# filename with timestamp
filename="postgres-$(date +%Y-%m-%d_%H-%M-%S).sql"
# perform pg_dump
pg_dump -U postgres postgres > /tmp/$filename
# upload to s3
aws s3 cp /tmp/$filename s3://$S3_BUCKET_NAME/$filename