Skip to content

Instantly share code, notes, and snippets.

@23Pstars
Created Oct 5, 2021
Embed
What would you like to do?
#!/bin/bash
DB_HOST={{db_name}}
DB_NAME={{db_name}}
DB_USER={{db_user}}
DB_PASS={{db_pass}}
S3_PATH=path/to/app/
FILE_NAME=mysql-$(date +%Y%m%d-%H_%M_%S)
echo "dump db..."
mysqldump -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME > $FILE_NAME.sql
echo "compress..."
tar -czvf $FILE_NAME.tar.gz $FILE_NAME.sql
echo "put to s3..."
s3cmd put $FILE_NAME.tar.gz s3://$S3_PATH
echo "clean up..."
rm -f $FILE_NAME*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment