Skip to content

Instantly share code, notes, and snippets.

@mahemoff mahemoff/backup.sh
Created Feb 2, 2019

Embed
What would you like to do?
mysql incremental backup
#!/bin/bash
function slice() {
lower=$1
upper=$(expr $lower + 100000)
echo "Backing up $lower"
mysqldump db_name table_name --opt --no-create-info --where "id > $lower and id <= $upper" | gzip -c | ssh user@host "cat > /home/backup/dump$lower.gz"
}
lower=0
while [ 1 ] ; do
if [ $lower -ge 60000000 ] ; then
echo done
exit 0
fi
lower=$(expr $lower + 100000)
slice $lower
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.