From b02208fe4c9777ec3ce7e203695149d87de5c2b5 Mon Sep 17 00:00:00 2001 From: Russ Long Date: Thu, 18 Aug 2022 14:06:59 +0000 Subject: [PATCH] Update config-example and b2backup, add ipabackup --- b2backup.sh | 3 +-- config-example.txt | 5 ++++- ipabackup.sh | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ipabackup.sh diff --git a/b2backup.sh b/b2backup.sh index 626a449..045523e 100644 --- a/b2backup.sh +++ b/b2backup.sh @@ -19,7 +19,6 @@ echo "Backup Complete. Currently available snapshots:" > $MAILFILE echo "
" >> $MAILFILE
 echo "$(/usr/bin/restic snapshots)" >> $MAILFILE
 
-
 (
 	echo "Subject: $EMAILSUB"
 	echo "From: $SENDER"
@@ -31,4 +30,4 @@ rm $MAILFILE
 
 for var in $(awk -F"=" '{print $1}' ${PWD}/config.txt); do
     unset $var
-done
\ No newline at end of file
+done
diff --git a/config-example.txt b/config-example.txt
index 5c66933..a1b1086 100644
--- a/config-example.txt
+++ b/config-example.txt
@@ -20,4 +20,7 @@ PGSQL_PATH=/path/to/sqlbackups/postgres
 MYSQL_PATH=/path/to/sqlbackups/mysql
 SQL_AUTH_FILE=/path/to/sqlauth.txt
 PGSQL_CONTAINER_NAMES="space separated list of containers running pgsql"
-MYSQL_CONTAINER_NAMES="space separated list of containers running mysql or mariadb"
\ No newline at end of file
+MYSQL_CONTAINER_NAMES="space separated list of containers running mysql or mariadb"
+IPA_EMAILSUB="FreeIPA Backup Complete"
+IPA_CONTAINERNAME="freeipa-master-1"
+IPA_BACKUP_PATH="/opt/ipabackups"
\ No newline at end of file
diff --git a/ipabackup.sh b/ipabackup.sh
new file mode 100644
index 0000000..5a0ebc4
--- /dev/null
+++ b/ipabackup.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+MAILFILE="/tmp/ipamailtxt"
+SERVER_NAME=$HOSTNAME
+SENDER=$(whoami)
+USER="noreply"
+MAILHEADER="/opt/b2backup/mailheader.txt"
+MAILFOOTER="/opt/b2backup/mailfooter.txt"
+. ${PWD}/config.txt
+
+export CONTNAME="$IPA_CONTAINER_NAME"
+export BACKUP_PATH="$IPA_BACKUP_PATH"
+
+docker exec $CONTNAME ipa-backup > /dev/null 2>&1
+
+echo "FreeIPA Backup Complete.  Currently available backups:" > $MAILFILE
+echo "
" >> $MAILFILE
+echo "$(ls -1 $BACKUP_PATH | sort -nr)" >> $MAILFILE
+
+(
+	echo "Subject: $EMAILSUB"
+	echo "From: $SENDER"
+	echo "To: $RECIPIENT"
+	cat $MAILHEADER $MAILFILE $MAILFOOTER
+) | sendmail -t