Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bandwidth limit #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion mysqltos3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ MYSQLROOT=root
MYSQLPASS=password
S3BUCKET=bucketname
FILENAME=filename
# bindwidth unit: kB/s (KiloBytes per second)
# to enable BANDWIDTH you should install trickle and libevent which tickle depends on (e.g. yum install libevent-devel && yum install trickle)
BANDWIDTH=256
DATABASE='--all-databases'
# the following line prefixes the backups with the defined directory. it must be blank or end with a /
S3PATH=mysql_backup/
Expand Down Expand Up @@ -56,7 +59,12 @@ echo "Past backup moved."

# upload all databases
echo "Uploading the new backup..."
s3cmd put -f ${TMP_PATH}${FILENAME}${DATESTAMP}.tar.gz s3://${S3BUCKET}/${S3PATH}${PERIOD}/
if command -v trickle >/dev/null 2>&1; then
echo "Limit bandwidth to ${BANDWIDTH}kB/s"
trickle -s -u ${BANDWIDTH} s3cmd put -f ${TMP_PATH}${FILENAME}${DATESTAMP}.tar.gz s3://${S3BUCKET}/${S3PATH}${PERIOD}/
else
s3cmd put -f ${TMP_PATH}${FILENAME}${DATESTAMP}.tar.gz s3://${S3BUCKET}/${S3PATH}${PERIOD}/
fi
echo "New backup uploaded."

echo "Removing the cache files..."
Expand Down