From 88851020d453bbebd70315f95a2ca710b7c536a4 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sat, 15 Mar 2025 16:14:08 -0500 Subject: [PATCH] Make the Let's Encrypt backup an email attachment. --- README.org | 13 ++++++++++++- roles_t/abbey-front/files/cron.daily_letsencrypt | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 7415d1a..fdb1dc4 100644 --- a/README.org +++ b/README.org @@ -756,9 +756,20 @@ cd /etc/ && diff -rq letsencrypt/ letsencrypt~/ \ && exit 0 +F=`date "+%Y%m%d"`.tar.gz ( echo "Subject: New /etc/letsencrypt/ on Droplet." echo "" - tar czf - letsencrypt/ \ + ( echo "Content-Type: multipart/mixed; boundary=\"boundary\"" + echo "MIME-Version: 1.0" + echo "" + echo "--boundary" + echo "Content-Type: application/gzip; name=\"$F\"" + echo "Content-Disposition: attachment; filename=\"$F\"" + echo "Content-Transfer-Encoding: base64" + echo "" + tar czf - letsencrypt/ | base64 + echo "" + echo "--boundary--" ) \ | gpg --encrypt --armor \ --trust-model always --recipient root@core ) \ | sendmail root \ diff --git a/roles_t/abbey-front/files/cron.daily_letsencrypt b/roles_t/abbey-front/files/cron.daily_letsencrypt index 24c4eef..2dca228 100644 --- a/roles_t/abbey-front/files/cron.daily_letsencrypt +++ b/roles_t/abbey-front/files/cron.daily_letsencrypt @@ -6,9 +6,20 @@ cd /etc/ && diff -rq letsencrypt/ letsencrypt~/ \ && exit 0 +F=`date "+%Y%m%d"`.tar.gz ( echo "Subject: New /etc/letsencrypt/ on Droplet." echo "" - tar czf - letsencrypt/ \ + ( echo "Content-Type: multipart/mixed; boundary=\"boundary\"" + echo "MIME-Version: 1.0" + echo "" + echo "--boundary" + echo "Content-Type: application/gzip; name=\"$F\"" + echo "Content-Disposition: attachment; filename=\"$F\"" + echo "Content-Transfer-Encoding: base64" + echo "" + tar czf - letsencrypt/ | base64 + echo "" + echo "--boundary--" ) \ | gpg --encrypt --armor \ --trust-model always --recipient root@core ) \ | sendmail root \ -- 2.25.1