backup/acme.sh

28 lines
744 B
Bash
Raw Normal View History

2024-08-08 05:50:15 +05:00
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo -e "\033[31mThis script requires superuser rights\033[0m"
exit 0
fi
2024-08-14 10:49:57 +05:00
LE_DIR="/data/secrets/$SERVER_DOMAIN/letsencrypt"
BACKUP_DIR="/backups/letsencrypt"
2024-08-08 05:50:15 +05:00
ARCHIVE_FILE="$BACKUP_DIR/$SERVER_DOMAIN.tar.gz"
# load ACME_BACKUP_PASSWORD
SECRETS_PATH=/data/secrets/$SERVER_DOMAIN/$SERVER_DOMAIN.env
2024-08-14 10:49:57 +05:00
trap 'echo -e "\033[31macme.sh: Something went wrong\033[0m"; exit 1' EXIT
2024-08-08 05:50:15 +05:00
set -e
export DEBIAN_FRONTEND=noninteractive
2024-08-14 10:49:57 +05:00
source $SECRETS_PATH
echo 'check BACKUP_DIR...'
mkdir -p "$BACKUP_DIR"
tar -czf - -C "$LE_DIR" . | openssl enc -aes-256-cbc -e -out "$ARCHIVE_FILE" -pass pass:"$ACME_BACKUP_PASSWORD" -pbkdf2 -iter 100000
2024-08-08 05:50:15 +05:00
trap - EXIT
2024-08-14 10:49:57 +05:00
echo "$LE_DIR backuped successfully to $ARCHIVE_FILE"