Created
February 2, 2019 17:19
-
-
Save mahemoff/73203184cc3754ad1783427685ef0036 to your computer and use it in GitHub Desktop.
mysql incremental backup
This file contains 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 | |
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