X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprofile%2Fmanifests%2Fpostgresql%2Fbackup_dump.pp;h=cae20f748180833d4fe4065ebcfe43472516a9a4;hb=33d0c69450127732c7105145b5e587811ffd644b;hp=5f456ed37060bd4393caf7dd05aabe813623e66f;hpb=bff7d1b743bc2239d7ce7ced37dd03e4e846c03d;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/modules/profile/manifests/postgresql/backup_dump.pp b/modules/profile/manifests/postgresql/backup_dump.pp index 5f456ed..cae20f7 100644 --- a/modules/profile/manifests/postgresql/backup_dump.pp +++ b/modules/profile/manifests/postgresql/backup_dump.pp @@ -30,32 +30,60 @@ define profile::postgresql::backup_dump ( $pg_port_arg = "" } - cron::job::multiple { "backup_psql_$pg_host": - ensure => "present", - require => [File[$pg_backup_path], File[$pg_path]], - jobs => [ - { - command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", - user => $pg_user, - hour => "22,4,10,16", - minute => 0, - description => "Backup the database", - }, - { - command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')", - user => $pg_user, - hour => 3, - minute => 0, - description => "Cleanup the database backups", - }, - { - command => "cd $pg_backup_path ; /usr/bin/rm -f $(ls -1 *T22*.sql | log2rotate --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M:%S+02:00.sql')", - user => $pg_user, - hour => 3, - minute => 1, - description => "Cleanup the database backups exponentially", - }, - ] + file { "/usr/local/sbin/backup_psql_$pg_host.sh": + mode => "0755", + content => template("profile/postgresql/backup_psql.sh.erb"), + } + + if ($pg_host == "eldiron.immae.eu") { + cron::job::multiple { "backup_psql_$pg_host": + ensure => "present", + require => [File[$pg_backup_path], File[$pg_path]], + jobs => [ + { + command => "/usr/local/sbin/backup_psql_$pg_host.sh", + user => $pg_user, + hour => "22,4,10,16", + minute => 0, + description => "Backup the database", + }, + { + command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | sort -r | sed -e '1,12d')", + user => $pg_user, + hour => 3, + minute => 0, + description => "Cleanup the database backups", + }, + ] + } + } else { + cron::job::multiple { "backup_psql_$pg_host": + ensure => "present", + require => [File[$pg_backup_path], File[$pg_path]], + jobs => [ + { + command => "/usr/local/sbin/backup_psql_$pg_host.sh", + user => $pg_user, + hour => "22,4,10,16", + minute => 0, + description => "Backup the database", + }, + { + command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')", + user => $pg_user, + hour => 3, + minute => 0, + description => "Cleanup the database backups", + }, + { + command => "cd $pg_backup_path ; /usr/bin/rm -f $(ls -1 *T22*.sql | log2rotate --skip 7 --fuzz 7 --delete --format='\%Y-\%m-\%dT\%H:\%M:\%S+02:00.sql')", + user => $pg_user, + hour => 3, + minute => 1, + description => "Cleanup the database backups exponentially", + }, + ] + } } @profile::monitoring::local_service { "Last postgresql dump in $pg_backup_path is not too old": @@ -63,7 +91,7 @@ define profile::postgresql::backup_dump ( "naemon-postgresql-dumps-$pg_host" => "naemon ALL=($pg_user) NOPASSWD: /usr/bin/find $pg_backup_path -mindepth 1 -maxdepth 1 -printf %T@?n", }, local => { - check_command => "check_last_file_date!$pg_backup_path!10!$pg_user", + check_command => "check_last_file_date!$pg_backup_path!7!$pg_user", } } }