Created
October 12, 2021 18:26
-
-
Save vuthaihoc/07c2f1160d19c22fe43e4548dd8e2fe7 to your computer and use it in GitHub Desktop.
Dump db and put to s3 by minio client
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 | |
# file /var/www/backup.sh | |
# Run `cd /var/www && sh backup.sh` | |
# This script is used for laravel projects deployed by deployer php | |
function run_backup(){ | |
export $(cat current/.env | sed 's/#.*//g' | xargs) | |
export MYSQL_PWD=$DB_PASSWORD | |
export TODAY=`date +%Y%m%d` | |
echo "Dumping database" | |
mysqldump -u $DB_USERNAME $DB_DATABASE \ | |
--no-tablespaces \ | |
--single-transaction=TRUE --verbose | \ | |
gzip > $DB_DATABASE.$TODAY.sql.gz && \ | |
echo "Uploading" && \ | |
mc cp $DB_DATABASE.$TODAY.sql.gz play/bucket/db1month/$DB_DATABASE.$TODAY.sql.gz && \ | |
rm -f $DB_DATABASE.$TODAY.sql.gz | |
} | |
dirs=($(find . -maxdepth 1 -type d -name 'deploy.*')) | |
for dir in "${dirs[@]}"; do | |
cd "$dir" | |
pwd | |
run_backup | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment