This commit is contained in:
Your Name
2025-05-03 23:03:16 +12:00
parent 340170b248
commit 2fe7d4c3d9
5 changed files with 2 additions and 466 deletions

View File

@ -3,40 +3,10 @@ source "${AGENT_PATH}/_common.sh"
# Nginx Example Backup Script
# Load service environment variables
source ./service.env
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
BACKUP_FILE="$1"
# hot backup is fine for nginx website content.
if [ -z "$BACKUP_FILE" ]; then
_die "Backup file path not provided"
fi
if [ -e "$BACKUP_FILE" ]; then
_die "Backup file $BACKUP_FILE already exists"
fi
echo "Backing up data for ${CONTAINER_NAME} from ${LOCAL_DATA_FOLDER} to ${BACKUP_FILE}..."
# Stop container before backup?
# echo "Stopping container ${CONTAINER_NAME} for backup..."
# _stop_container "$CONTAINER_NAME"
# Create backup of data folder
tar -czf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .
# Check if backup command was successful
if [ $? -ne 0 ]; then
# Start container again if it was stopped
# echo "Restarting container ${CONTAINER_NAME}..."
# _start_container "$CONTAINER_NAME"
_die "Failed to create backup"
fi
# Start container again if it was stopped
# echo "Restarting container ${CONTAINER_NAME}..."
# _start_container "$CONTAINER_NAME"
autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
echo "Backup complete: ${BACKUP_FILE}"