Created
May 7, 2019 07:26
-
-
Save 23Pstars/02ebccd4ea690d20894ab276a006de75 to your computer and use it in GitHub Desktop.
Dump and backup MySQL database to S3 server
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 | |
# | |
# LRsoft Corp. | |
# https://lrsoft.co.id | |
# | |
# Author: Zaf | |
# Date: 10/22/18 | |
# Time: 10:01 AM | |
# install https://s3tools.org/download first | |
# config | |
DB_NAME=db | |
DB_USER=user | |
DB_PASS=pass | |
S3_PATH=path/to/s3/dir/ | |
FILE_NAME=mysql-$(date +%Y%m%d-%H_%M_%S) | |
echo "dump db..." | |
mysqldump -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