From c6a29ebe788799aa75ebc7a4e436915048221b39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 11 Jan 2019 15:56:36 +0100 Subject: [PATCH] Add specific cron for eldiron psql replication --- .../manifests/postgresql/backup_dump.pp | 75 ++++++++++++------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/modules/profile/manifests/postgresql/backup_dump.pp b/modules/profile/manifests/postgresql/backup_dump.pp index fcc2085..7578027 100644 --- a/modules/profile/manifests/postgresql/backup_dump.pp +++ b/modules/profile/manifests/postgresql/backup_dump.pp @@ -30,32 +30,55 @@ 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", - }, - ] + 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/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 | 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/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", + }, + ] + } } @profile::monitoring::local_service { "Last postgresql dump in $pg_backup_path is not too old": -- 2.41.0