Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created February 2, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/73203184cc3754ad1783427685ef0036 to your computer and use it in GitHub Desktop.
Save mahemoff/73203184cc3754ad1783427685ef0036 to your computer and use it in GitHub Desktop.
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