diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-06-24 21:25:13 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-06-24 23:41:46 +0200 |
commit | 80225f1917ac5919135af2a4815fce5faf3fa080 (patch) | |
tree | eb58c5f0b18188989e3d2a2a61b15b80a0a2613c /modules | |
parent | 851ca3c6f662e26e949e57669d7962abb6c22510 (diff) | |
download | Puppet-80225f1917ac5919135af2a4815fce5faf3fa080.tar.gz Puppet-80225f1917ac5919135af2a4815fce5faf3fa080.tar.zst Puppet-80225f1917ac5919135af2a4815fce5faf3fa080.zip |
Add pylog2rotate for backups
Diffstat (limited to 'modules')
-rw-r--r-- | modules/role/manifests/backup.pp | 8 | ||||
-rw-r--r-- | modules/role/manifests/backup/postgresql.pp | 9 |
2 files changed, 16 insertions, 1 deletions
diff --git a/modules/role/manifests/backup.pp b/modules/role/manifests/backup.pp index b35c542..51b689d 100644 --- a/modules/role/manifests/backup.pp +++ b/modules/role/manifests/backup.pp | |||
@@ -17,6 +17,14 @@ class role::backup ( | |||
17 | 17 | ||
18 | include "role::backup::postgresql" | 18 | include "role::backup::postgresql" |
19 | 19 | ||
20 | ensure_packages(["python", "python-pip"]) | ||
21 | package { "pylog2rotate": | ||
22 | source => "git+https://github.com/avian2/pylog2rotate", | ||
23 | ensure => present, | ||
24 | provider => "pip3", | ||
25 | require => Package["python-pip"], | ||
26 | } | ||
27 | |||
20 | ensure_packages(["rsync"]) | 28 | ensure_packages(["rsync"]) |
21 | 29 | ||
22 | ssh_keygen { $user: | 30 | ssh_keygen { $user: |
diff --git a/modules/role/manifests/backup/postgresql.pp b/modules/role/manifests/backup/postgresql.pp index e635611..e891195 100644 --- a/modules/role/manifests/backup/postgresql.pp +++ b/modules/role/manifests/backup/postgresql.pp | |||
@@ -153,12 +153,19 @@ class role::backup::postgresql inherits role::backup { | |||
153 | description => "Backup the database", | 153 | description => "Backup the database", |
154 | }, | 154 | }, |
155 | { | 155 | { |
156 | command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | sort -r | sed -e '1,16d')", | 156 | command => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | grep -v 'T22:' | sort -r | sed -e '1,12d')", |
157 | user => $pg_user, | 157 | user => $pg_user, |
158 | hour => 3, | 158 | hour => 3, |
159 | minute => 0, | 159 | minute => 0, |
160 | description => "Cleanup the database backups", | 160 | description => "Cleanup the database backups", |
161 | }, | 161 | }, |
162 | { | ||
163 | 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')", | ||
164 | user => $pg_user, | ||
165 | hour => 3, | ||
166 | minute => 1, | ||
167 | description => "Cleanup the database backups exponentially", | ||
168 | }, | ||
162 | ] | 169 | ] |
163 | } | 170 | } |
164 | 171 | ||