This commit is contained in:
Your Name
2025-05-03 23:18:52 +12:00
parent 2fe7d4c3d9
commit 3d9b1fa6d2
48 changed files with 59 additions and 199 deletions

View File

@ -1,29 +1,13 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
# Get backup file path from argument
BACKUP_FILE="$1"
if [ -z "$BACKUP_FILE" ]; then
die "Backup file path not provided"
fi
# Check if backup file already exists
if [ -f "$BACKUP_FILE" ]; then
die "Backup file $BACKUP_FILE already exists"
fi
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# Stop container before backup
_stop_container "$CONTAINER_NAME"
# Create backup of data folder
# We include the parent folder in the backup paths (.), and strip on restore.
echo "Creating backup of $LOCAL_DATA_FOLDER..."
if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
_start_container "$CONTAINER_NAME"
die "Failed to create backup"
fi
autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
# Start container after backup
_start_container "$CONTAINER_NAME"
echo "Backup created successfully: $BACKUP_FILE"
echo "Backup created successfully"