Last active
December 27, 2024 13:53
-
-
Save fishuke/e9ad15894cc69a7a88185282053c3ffb to your computer and use it in GitHub Desktop.
backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| apk add --no-cache aws-cli | |
| export AWS_ACCESS_KEY_ID="0f7324bda21608af1b192376a550a6eb" | |
| export AWS_SECRET_ACCESS_KEY="872eaa73eb027b39f4859e48c788e8279724a5dc579fe31eeff0d90fdf728fb9" | |
| export AWS_DEFAULT_REGION="us-east-1" | |
| pg_dump --format=custom --no-acl --no-owner --username=$POSTGRES_USER $POSTGRES_DB > /tmp/backup.dump | |
| [ $? -eq 0 ] || { echo "Error creating backup. Exiting..."; exit 1; } | |
| aws s3 cp /tmp/backup.dump s3://sixtynine-backups/backup_$(date +%F_%H-%M-%S).dump --endpoint-url=https://6b6568edfbac3b9600fff1b56b988488.r2.cloudflarestorage.com | |
| [ $? -eq 0 ] && rm /tmp/backup.dump || { echo "Error uploading backup. Exiting..."; exit 1; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment