30 lines
778 B
Bash
30 lines
778 B
Bash
#!/bin/bash
|
|
source "$(dirname "$0")/_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
|
|
|
|
# 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
|
|
|
|
# Start container after backup
|
|
_start_container "$CONTAINER_NAME"
|
|
|
|
echo "Backup created successfully: $BACKUP_FILE"
|