User Tools

Site Tools


Sidebar

code:git:hooks

Hooks

MySQL dump hook

#!/bin/sh
#
# MySQL database backup script
#
 
set -e
 
db_name="<target-database>"
db_user="<database-user>"
db_pass="<database-password>"
db_dir="<target-dir-for-dumps>"
 
shared_params="--compatible=mysql40 --compact"
 
# generate a new schema
mysqldump -u $db_user --password=$db_pass $shared_params --no-data $db_name > $db_dir/$db_name.structure.sql
mysqldump -u $db_user --password=$db_pass $shared_params --no-create-info --skip-extended-insert $db_name > $db_dir/$db_name.skip-extended-insert.sql
 
git add $db_dir/$db_name.skip-extended-insert.sql
git add $db_dir/$db_name.structure.sql
 
# Exit success
exit 0
code/git/hooks.txt · Last modified: 2011/03/20 19:39 (external edit)