backups
This commit is contained in:
@ -1,24 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source common functions
|
||||
source "$(dirname "$0")/_dockerhelper.sh"
|
||||
source "$(dirname "$0")/_common.sh"
|
||||
|
||||
# Load environment variables
|
||||
load_env "$1" || die "Failed to load environment variables"
|
||||
|
||||
# set the backup file name to be the current date and time
|
||||
BACKUP_FILE="$BACKUP_FOLDER/backup-squashkiwi-$(date +%Y-%m-%d_%H-%M-%S).tar.gz"
|
||||
|
||||
if [ -f "$BACKUP_FILE" ]; then
|
||||
echo "Backup file $BACKUP_FILE already exists"
|
||||
exit 1
|
||||
# Get backup file path from second argument
|
||||
BACKUP_FILE="$2"
|
||||
if [ -z "$BACKUP_FILE" ]; then
|
||||
die "Backup file path not provided"
|
||||
fi
|
||||
|
||||
stop_container
|
||||
# Check if backup file already exists
|
||||
if [ -f "$BACKUP_FILE" ]; then
|
||||
die "Backup file $BACKUP_FILE already exists"
|
||||
fi
|
||||
|
||||
# create the backup file, using relative paths.
|
||||
tar zcvf "$BACKUP_FILE" -C "$DATA_FOLDER" . || die "Failed to create backup"
|
||||
# Stop container before backup
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
|
||||
start_container
|
||||
# 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
|
||||
|
||||
echo "Backup created in $BACKUP_FILE"
|
||||
# Start container after backup
|
||||
_start_container "$CONTAINER_NAME"
|
||||
|
||||
echo "Backup created successfully: $BACKUP_FILE"
|
||||
|
Reference in New Issue
Block a user