Created
June 27, 2019 21:12
-
-
Save ngstigator/ddb6d65a7d3b501b81182a15e2431abd to your computer and use it in GitHub Desktop.
AWS S3 backup cron-able script
This file contains 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 | |
export HOME="/home/web" | |
export AWS_CONFIG_FILE="/home/web/.aws/config" | |
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX | |
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
BACKUP_DIR=/home/web/db/$(date +%Y) | |
DB_FILE=$(ls $BACKUP_DIR -tp |grep -v /$ | head -1) | |
/home/web/.local/bin/aws s3 cp $BACKUP_DIR/$DB_FILE s3://{bucket}/{data}/{environment}/$(date +%Y)/$DB_FILE 2>&1 | |
#echo $DB_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment