Purge binlogs regularly
This commit is contained in:
parent
8386df91de
commit
6dfe1496a4
2 changed files with 15 additions and 0 deletions
|
@ -74,6 +74,11 @@ define sunetdrive::db_type(
|
|||
content => template($mycnf_path),
|
||||
mode => '0744',
|
||||
}
|
||||
file { '/usr/local/bin/purge-binlogs':
|
||||
ensure => present,
|
||||
content => template('sunetdrive/mariadb/purge-binlogs.erb.sh'),
|
||||
mode => '0744',
|
||||
}
|
||||
file { "${mariadb_dir}/scripts/run_manual_backup_dump.sh":
|
||||
ensure => present,
|
||||
content => template('sunetdrive/mariadb/run_manual_backup_dump.erb.sh'),
|
||||
|
@ -84,6 +89,13 @@ define sunetdrive::db_type(
|
|||
content => template('sunetdrive/mariadb/rename-docker.sh'),
|
||||
mode => '0744',
|
||||
}
|
||||
sunet::scriptherder::cronjob { 'purge_binlogs':
|
||||
cmd => "/usr/local/bin/purge-binlogs",
|
||||
hour => '6',
|
||||
minute => '0',
|
||||
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||
}
|
||||
if $is_multinode {
|
||||
$docker_compose = $override_compose
|
||||
} else {
|
||||
|
|
3
templates/mariadb/purge-binlogs.erb.sh
Normal file
3
templates/mariadb/purge-binlogs.erb.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
six_hours_ago=$(date -d "6 hours ago" "+%Y-%m-%d %H:%M:%S")
|
||||
docker exec mariadb_db_1 mysql -u root -p'<%= @mysql_root_password %>' -N -B -e "PURGE BINARY LOGS BEFORE '${six_hours_ago}'"
|
Loading…
Add table
Reference in a new issue