Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ngstigator/ddb6d65a7d3b501b81182a15e2431abd to your computer and use it in GitHub Desktop.
Save ngstigator/ddb6d65a7d3b501b81182a15e2431abd to your computer and use it in GitHub Desktop.
AWS S3 backup cron-able script
#!/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