diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-11 15:56:36 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-11 15:56:52 +0100 |
commit | c6a29ebe788799aa75ebc7a4e436915048221b39 (patch) | |
tree | b7893c221bc2ae67c977543d968f660335212455 | |
parent | 98776befc7635f5a92670f66e991d39e8beb599e (diff) | |
download | Puppet-c6a29ebe788799aa75ebc7a4e436915048221b39.tar.gz Puppet-c6a29ebe788799aa75ebc7a4e436915048221b39.tar.zst Puppet-c6a29ebe788799aa75ebc7a4e436915048221b39.zip |
Add specific cron for eldiron psql replication
-rw-r--r-- | modules/profile/manifests/postgresql/backup_dump.pp | 75 |
1 files 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 ( | |||
30 | $pg_port_arg = "" | 30 | $pg_port_arg = "" |
31 | } | 31 | } |
32 | 32 | ||
33 | cron::job::multiple { "backup_psql_$pg_host": | 33 | if ($pg_host == "eldiron.immae.eu") { |
34 | ensure => "present", | 34 | cron::job::multiple { "backup_psql_$pg_host": |
35 | require => [File[$pg_backup_path], File[$pg_path]], | 35 | ensure => "present", |
36 | jobs => [ | 36 | require => [File[$pg_backup_path], File[$pg_path]], |
37 | { | 37 | jobs => [ |
38 | command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", | 38 | { |
39 | user => $pg_user, | 39 | command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", |
40 | hour => "22,4,10,16", | 40 | user => $pg_user, |
41 | minute => 0, | 41 | hour => "22,4,10,16", |
42 | description => "Backup the database", | 42 | minute => 0, |
43 | }, | 43 | description => "Backup the database", |
44 | { | 44 | }, |
45 | command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')", | 45 | { |
46 | user => $pg_user, | 46 | command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | sort -r | sed -e '1,12d')", |
47 | hour => 3, | 47 | user => $pg_user, |
48 | minute => 0, | 48 | hour => 3, |
49 | description => "Cleanup the database backups", | 49 | minute => 0, |
50 | }, | 50 | description => "Cleanup the database backups", |
51 | { | 51 | }, |
52 | 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')", | 52 | ] |
53 | user => $pg_user, | 53 | } |
54 | hour => 3, | 54 | } else { |
55 | minute => 1, | 55 | cron::job::multiple { "backup_psql_$pg_host": |
56 | description => "Cleanup the database backups exponentially", | 56 | ensure => "present", |
57 | }, | 57 | require => [File[$pg_backup_path], File[$pg_path]], |
58 | ] | 58 | jobs => [ |
59 | { | ||
60 | command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", | ||
61 | user => $pg_user, | ||
62 | hour => "22,4,10,16", | ||
63 | minute => 0, | ||
64 | description => "Backup the database", | ||
65 | }, | ||
66 | { | ||
67 | command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')", | ||
68 | user => $pg_user, | ||
69 | hour => 3, | ||
70 | minute => 0, | ||
71 | description => "Cleanup the database backups", | ||
72 | }, | ||
73 | { | ||
74 | 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')", | ||
75 | user => $pg_user, | ||
76 | hour => 3, | ||
77 | minute => 1, | ||
78 | description => "Cleanup the database backups exponentially", | ||
79 | }, | ||
80 | ] | ||
81 | } | ||
59 | } | 82 | } |
60 | 83 | ||
61 | @profile::monitoring::local_service { "Last postgresql dump in $pg_backup_path is not too old": | 84 | @profile::monitoring::local_service { "Last postgresql dump in $pg_backup_path is not too old": |