diff --git a/templates/squashkiwi/_backup.sh b/templates/squashkiwi/_backup.sh new file mode 100644 index 0000000..c527ea8 --- /dev/null +++ b/templates/squashkiwi/_backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash +source "$(dirname "$0")/_common.sh" +load_env "$1" || die "Failed to load environment variables" + +# Get backup file path from second argument +BACKUP_FILE="$2" +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 + +# Stop container before backup +_stop_container "$CONTAINER_NAME" + +# Create backup of data folder +echo "Creating backup of $DATA_FOLDER..." +if ! tar zcvf "$BACKUP_FILE" -C "$DATA_FOLDER" .; then + _start_container "$CONTAINER_NAME" + die "Failed to create backup" +fi + +# Start container after backup +_start_container "$CONTAINER_NAME" + +echo "Backup created successfully: $BACKUP_FILE" diff --git a/templates/squashkiwi/_status.sh b/templates/squashkiwi/_status.sh index e4a2c70..0a82bd2 100644 --- a/templates/squashkiwi/_status.sh +++ b/templates/squashkiwi/_status.sh @@ -1,11 +1,6 @@ #!/bin/bash - -# Source common functions -source "$(dirname "$0")/_dockerhelper.sh" source "$(dirname "$0")/_common.sh" - -# Load environment variables -load_env "$1" || exit 1 +load_env "$1" || die "Failed to load environment variables" # check if the service is running _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."