Skip to content

Commit

Permalink
compress backup with xz
Browse files Browse the repository at this point in the history
  • Loading branch information
eltorio committed Dec 8, 2023
1 parent b7df3ab commit 83c1076
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ WORKDIR /app/
# Install system dependencies
RUN set -ex; \
apk add --update --no-cache \
pwgen netcat-openbsd bash imagemagick curl acme.sh &&\
pwgen netcat-openbsd bash imagemagick curl acme.sh xz &&\
echo "23 20 * * 0 /autobackup" >> /etc/crontabs/root &&\
echo "*/10 * * * * sleep \$((\`od -vAn -N2 -tu2 < /dev/urandom\` %300)) ; /update-cloudflare-dns.sh" >> /etc/crontabs/root &&\
echo "0 0 * * 0 sleep \$((\`od -vAn -N2 -tu2 < /dev/urandom\` %14400)) ; acme.sh --renew-all --config-home /app/server/files/certs/config" >> /etc/crontabs/root
Expand Down
16 changes: 8 additions & 8 deletions scripts/autobackup
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
MAILUSER=`cat /app/zone-mta/config/builtin-zonemta.json |sed -n 's/^.*\"user\":.*\"\(.*\)\",$/\1/p'`
MAILPASSWD=`cat /app/zone-mta/config/builtin-zonemta.json |sed -n 's/^.*\"pass\":.*\"\(.*\)\"$/\1/p'`
MAILUSER=`cat /app/zone-mta/config/builtin-zonemta.json |sed -n 's/^.*\"user\":.*\"\(.*\)\",$/\1/p'| head -n1`
MAILPASSWD=`cat /app/zone-mta/config/builtin-zonemta.json |sed -n 's/^.*\"pass\":.*\"\(.*\)\"$/\1/p'| head -n1`
NOW=`date -I`
/usr/bin/mysqldump -h $MYSQL_HOST --password="$MYSQL_ROOT_PASSWORD" --all-databases | bzip2 -9 > /app/server/files/backup.sql.bz2
tar -cvjf /app/server/files/backup.tar.bz2 /app/server/files/backup.sql.bz2 /app/server/files/campaign /app/server/files/certs /app/server/files/imports /app/server/files/reports /app/server/files/template /app/server/files/uploaded
/usr/bin/mysqldump -h $MYSQL_HOST --password="$MYSQL_ROOT_PASSWORD" --all-databases | xz -9 > /app/server/files/backup.sql.xz
tar -cvJf /app/server/files/backup.tar.xz /app/server/files/backup.sql.xz /app/server/files/campaign /app/server/files/certs /app/server/files/imports /app/server/files/reports /app/server/files/template /app/server/files/uploaded
(
cat << EOF
From: "SAUVEGARDE @HCFMailer+" <$BACKUP_FROM>
Expand All @@ -22,10 +22,10 @@ Voici la sauvegarde du $NOW
HCFMailer+ team
---
Content-Type: application/octet-stream; name="backup-$NOW.tar.bz2"
Content-Type: application/octet-stream; name="backup-$NOW.tar.xz"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="backup-$NOW.tar.bz2"
Content-Disposition: inline; filename="backup-$NOW.tar.xz"
EOF
) | (cat - && /usr/bin/openssl base64 < /app/server/files/backup.tar.bz2 && echo "" && echo "---")\
| /usr/sbin/sendmail -f $BACKUP_FROM -au$MAILUSER -ap$MAILPASSWD -amPLAIN -S 127.0.0.1:2525 -t --
) | (cat - && /usr/bin/openssl base64 < /app/server/files/backup.tar.xz && echo "" && echo "---")\
| /usr/sbin/sendmail -f $BACKUP_FROM -au$MAILUSER -ap$MAILPASSWD -amPLAIN -S 127.0.0.1:2525 -t --

0 comments on commit 83c1076

Please sign in to comment.