.
This commit is contained in:
parent
2d780eaffa
commit
1a4b82b361
29
templates/squashkiwi/_backup.sh
Normal file
29
templates/squashkiwi/_backup.sh
Normal file
@ -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"
|
@ -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."
|
||||
|
Loading…
x
Reference in New Issue
Block a user