introduce helpers for mysql backups

This commit is contained in:
mh 2013-02-18 22:13:56 +01:00 committed by Marcel Haerry
parent fc1210bea8
commit 6d9a846867
3 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,17 @@
#!/bin/bash
file=$1
db=$2
table=$3
if [ ! -f $file ] || [ -z $db ]; then
echo "USAGE: $0 file database [table] > dump_file"
exit
fi
if [ -z $table ]; then
zcat $file | sed -n -e "/CREATE DATABASE.*${db}/,/CREATE DATABASE/p" | head -n -5
else
zcat $file | sed -n -e "/CREATE DATABASE.*${db}/,/CREATE DATABASE/p" | sed -n -e "/CREATE TABLE.*${table}/,/CREATE TABLE/p" | head -n -8
fi

View file

@ -0,0 +1,11 @@
# Helpers for mysql servers
# In a dedicated class so they can
# also be pulled in somewhere else
class mysql::server::backup_helpers{
file{'/usr/local/bin/mysql_extract_from_backup':
source => 'puppet:///modules/mysql/backup_helpers/mysql_extract_from_backup.sh',
owner => root,
group => 0,
mode => '0555';
}
}

View file

@ -66,6 +66,7 @@ class mysql::server::base {
if $mysql::server::backup_cron {
include mysql::server::cron::backup
include mysql::server::backup_helpers
}
if $mysql::server::optimize_cron {