backup/acme.sh

24 lines
731 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
ACME_FILE="/data/secrets/$SERVER_DOMAIN/letsencrypt/$SERVER_DOMAIN.acme.json"
BACKUP_DIR="/backups/acme"
ARCHIVE_FILE="$BACKUP_DIR/$SERVER_DOMAIN.tar.gz"
# load ACME_BACKUP_PASSWORD
SECRETS_PATH=/data/secrets/$SERVER_DOMAIN/$SERVER_DOMAIN.env
source $SECRETS_PATH
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT
set -e
export DEBIAN_FRONTEND=noninteractive
tar -czf - -C "$ACME_FILE" . | openssl enc -aes-256-cbc -e -out "$ARCHIVE_FILE" -pass pass:"$ACME_BACKUP_PASSWORD" -pbkdf2 -iter 100000
trap - EXIT
echo "All backups were made successfully. Outdated backups have been deleted"