From 92a2bddb606c578b48f3af38bc2b3f2aadd5e1bf Mon Sep 17 00:00:00 2001 From: tpiccioli Date: Wed, 22 Sep 2021 11:35:24 +0200 Subject: [PATCH] backuppc ipa-backup script --- files/freeipa-backup.sh | 36 ++++++++++++++++++++++++++++++++++++ tasks/main.yml | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 files/freeipa-backup.sh diff --git a/files/freeipa-backup.sh b/files/freeipa-backup.sh new file mode 100644 index 0000000..ec05f86 --- /dev/null +++ b/files/freeipa-backup.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +TYPE=$1 +RETENTION=$2 +# parameters passed by backuppc + +BACKUP_DIR=/var/lib/ipa/backup + +if [ $RETENTION = '' ] +then + RETENTION=2 +fi + +cd $BACKUP_DIR + +# delete older ipa backups by counting fulls into account +OLDERFULL=`ls -1trd ipa-full-* | tail -$RETENTION | head -1` + +TODELETE=`find . -maxdepth 1 -type d -name 'ipa-*' ! -newer $OLDERFULL | grep -v $OLDERFULL | tr '\n' ' '` + +for i in $TODELETE +do + rm -rfv $i +done + +# execute full ipa backup with a full backuppc backup +if [ $TYPE = 'full' ] +then + ipa-backup +elif [ $TYPE = 'incr' ] +then + ipa-backup --data --online +else + echo "first parameter (type) must be full or incr" +fi + diff --git a/tasks/main.yml b/tasks/main.yml index 28bc9c0..cb08bc0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -79,3 +79,8 @@ - ansible_distribution_file_variety == "RedHat" - ipa_run_the_installation_command | bool tags: [ 'ipa' ] + +- name: backuppc root script for ipa-backup + copy: src=freeipa-backup.sh dest=/usr/local/sbin/freeipa-backup.sh owner=root mode=0744 + tags: [ 'ipa_backup', 'ipa' ] +