2024-05-17 21:33:53 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
datetime=`date +%Y%m%d%H`
|
|
|
|
|
2024-07-30 15:53:25 +08:00
|
|
|
mkdir -p ~/.aws
|
|
|
|
|
|
|
|
echo -ne "[default]\naws_access_key_id = ${AWS_ACCESS_KEY}\naws_secret_access_key = ${AWS_SECRET_KEY}\n" > ~/.aws/credentials
|
|
|
|
|
|
|
|
dbs=${DATABASES}
|
|
|
|
|
|
|
|
for db in ${dbs[@]};
|
|
|
|
do
|
|
|
|
mysqldump -h ${HOST} -P ${PORT} -u backup -p${PASSWORD} --single-transaction --set-gtid-purged=OFF $db > ${db}.sql
|
|
|
|
if (($?==0));then
|
|
|
|
aws s3 cp ${db}.sql s3://bfs-pkg-storage/mysql/backup/${datetime}/
|
|
|
|
else
|
|
|
|
echo "Backup to failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|