Skip to content

Instantly share code, notes, and snippets.

@slomo
Forked from AlexanderS/backup-mysql.sh
Created February 10, 2012 10:49
Show Gist options
  • Save slomo/1788725 to your computer and use it in GitHub Desktop.
Save slomo/1788725 to your computer and use it in GitHub Desktop.
#!/bin/bash
TARGET="/backup/mysql"
egrep -v "^(#|\\s*$)" /etc/duply/default/enabledDBs | while read DATABASE ; do
# this works securly for all tables in this database. It locks all tables (no read or write) and dumps them.
# Inculding creat db-statment. The quick options dumps to ram, and flushes then. This leads to less locktime.
mysqldump --lock-tables --quick --databases ${DATABASE} | gzip > ${TARGET}/${DATABASE}.mysql.gz
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment