#!/bin/bash # shellcheck source=ghost_server-env . "${HOME}"/"${USER}"-env mkdir -p "${HOME}"/backup_logs logFile=${HOME}/backup_logs/$(date +%y_%m).log { echo -e "\n[+] ghost backup\n" TMP_DIR="/tmp/${USER}-backup" mkdir -p "${TMP_DIR}" sudo docker compose -f "${HOME}"/"${USER}"-compose.yaml stop ghost # Dump database # shellcheck disable=SC2024 sudo docker exec ghost-mysql mysqldump \ -u root --password="${DB_ROOT_PASSWORD}" \ --no-tablespaces ghost >"${TMP_DIR}/db.sql" # Backup content (exclude logs) rsync -a --exclude='logs/' "${VOLUME_PATH}/content/" "${TMP_DIR}/content/" sudo docker compose -f "${HOME}"/"${USER}"-compose.yaml start ghost if ! rclone copy "${TMP_DIR}" "${BUCKET_PATH}" -v; then curl -Ss \ -H "Title: Ghost Blog" \ -H "Priority: 3" \ -H "Tags: warning,backup" \ -d "Backup not completed - rclone failure" \ "${NOTIF_URL}" rm -rf "${TMP_DIR}" exit 1 fi curl -Ss \ -H "Title: Ghost Blog" \ -H "Priority: 2" \ -H "Tags: heavy_check_mark,backup" \ -d "Backup completed" \ "${NOTIF_URL}" rm -rf "${TMP_DIR}" } &>>"$logFile"