introduce helpers for mysql backups
This commit is contained in:
parent
fc1210bea8
commit
6d9a846867
3 changed files with 29 additions and 0 deletions
17
files/backup_helpers/mysql_extract_from_backup.sh
Normal file
17
files/backup_helpers/mysql_extract_from_backup.sh
Normal 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
|
||||
|
11
manifests/server/backup_helpers.pp
Normal file
11
manifests/server/backup_helpers.pp
Normal 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';
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue