]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add pylog2rotate for backups
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 24 Jun 2018 19:25:13 +0000 (21:25 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 24 Jun 2018 21:41:46 +0000 (23:41 +0200)
modules/role/manifests/backup.pp
modules/role/manifests/backup/postgresql.pp

index b35c54270fbe2f573700ab782840fe10e32653b0..51b689d4a891feb84c40b01b7ae66fb6f606dc9f 100644 (file)
@@ -17,6 +17,14 @@ class role::backup (
 
   include "role::backup::postgresql"
 
+  ensure_packages(["python", "python-pip"])
+  package { "pylog2rotate":
+    source   => "git+https://github.com/avian2/pylog2rotate",
+    ensure   => present,
+    provider => "pip3",
+    require  => Package["python-pip"],
+  }
+
   ensure_packages(["rsync"])
 
   ssh_keygen { $user:
index e63561149e40de398a33818eafeeb2147c78cef6..e891195c83a72d977f49e5bf0707868c1a281960 100644 (file)
@@ -153,12 +153,19 @@ class role::backup::postgresql inherits role::backup {
           description => "Backup the database",
         },
         {
-          command     => "/usr/bin/rm -f $(ls -1 $pg_backup_path/*.sql | sort -r | sed -e '1,16d')",
+          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",
+        },
       ]
     }