Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmicoppai committed May 15, 2024
1 parent 338511c commit 9dc4bf4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
23 changes: 18 additions & 5 deletions xbackup/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@ check_mysql_data_dir() {
if [ ! -d "$DB_DATA_DIR" ]; then
echo "Error: MySQL data directory $DB_DATA_DIR does not exist."
exit 1
elif [ -z "$(ls -A "$DB_DATA_DIR")" ]; then
fi

if [ -z "$(ls -A "$DB_DATA_DIR")" ]; then
echo "Error: MySQL data directory $DB_DATA_DIR is empty."
exit 1
elif [ ! -f "$DB_DATA_DIR/ibdata1" ]; then
fi

if [ ! -f "$DB_DATA_DIR/ibdata1" ]; then
echo "Error: Critical file ibdata1 not found in MySQL data directory $DB_DATA_DIR."
exit 1
else
echo "MySQL data directory $DB_DATA_DIR is valid and contains the critical file."
fi
}

if [ ! -f "$DB_DATA_DIR/ib_logfile0" ] && [ ! -f "$DB_DATA_DIR/ib_logfile1" ]; then
echo "Error: No InnoDB redo log files (ib_logfile0, ib_logfile1) found in MySQL data directory $DB_DATA_DIR."
exit 1
fi

if [ ! -d "$DB_DATA_DIR/mysql" ]; then
echo "Error: MySQL system database directory not found in MySQL data directory $DB_DATA_DIR."
exit 1
fi

echo "MySQL data directory $DB_DATA_DIR is valid and contains the critical file."
}
check_mysql_data_dir

cat << EOF > /root/.s3cfg
Expand Down
4 changes: 2 additions & 2 deletions xbackup/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [ -f .env ]; then
echo "Loading environment variables from .env file"
set -o allexport
source .env
set -o allexport
set +o allexport
else
echo ".env file not found!"
exit 1
Expand Down Expand Up @@ -61,4 +61,4 @@ if [[ "${XBACKUP_VOLUME}" != /* ]]; then
export XBACKUP_VOLUME=$(get_abs_path "${XBACKUP_VOLUME}")
fi

run_cmd sudo docker compose up -d --build
run_cmd sudo docker compose up --build -d
23 changes: 21 additions & 2 deletions xbackup/xbackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
# Usage: ./xbackup.sh start (assuming .env is set correctly)
# ./xbackup.sh load
# ./xbackup.sh apply
# ./xbackup.sh logs
# ./xbackup.sh down


perform_backup() {
sudo chmod +x ./init.sh
sudo ./init.sh
}

Expand All @@ -13,7 +17,16 @@ prepare_backup() {
}

apply_backup() {
sudo ./apply.sh
sudo chmod _x ./apply.sh
sudo ./apply.sh
}

show_logs() {
sudo docker compose logs
}

stop() {
sudo docker compose down
}

case "$1" in
Expand All @@ -26,8 +39,14 @@ case "$1" in
"apply")
apply_backup
;;
"logs")
show_logs
;;
"down")
stop
;;
*)
echo "Usage: $0 [backup|prepare|apply]"
echo "Usage: $0 [start|load|apply|logs|down]"
exit 1
;;
esac
Expand Down

0 comments on commit 9dc4bf4

Please sign in to comment.